Configs2026年5月23日·1 分钟阅读

QuickJS — Small Embeddable JavaScript Engine

Lightweight JavaScript engine by Fabrice Bellard supporting the ES2023 specification in a single C file with no external dependencies.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
QuickJS Overview
通用 CLI 安装命令
npx tokrepo install fbf50eca-56e5-11f1-9bc6-00163e2b0d79

Introduction

QuickJS is a small, embeddable JavaScript engine written in C by Fabrice Bellard, the creator of FFmpeg and QEMU. It supports the full ES2023 specification including modules, async/await, generators, proxies, and BigInt. The engine compiles to a single binary under 700 KB, making it ideal for embedding in applications, IoT devices, and plugin systems where V8 or SpiderMonkey would be too heavy.

What QuickJS Does

  • Executes standard-compliant JavaScript including ES modules and async functions
  • Compiles JavaScript to bytecode for faster startup and smaller distribution
  • Provides a C API for embedding the engine in native applications
  • Includes a standalone qjs interpreter and a qjsc bytecode compiler
  • Supports operator overloading and BigFloat extensions for mathematical computing

Architecture Overview

QuickJS uses a bytecode interpreter with a reference-counting garbage collector supplemented by cycle detection. The parser produces an AST that is compiled to compact bytecode in a single pass. The engine is contained in two main C files (quickjs.c and quickjs-libc.c) with no third-party dependencies. Memory usage is predictable because the reference counter frees objects immediately when they become unreachable, avoiding the pause-time variance of tracing collectors.

Self-Hosting & Configuration

  • Build from source with make on any POSIX system or use CMake for cross-compilation
  • Embed by linking quickjs.c into your C or C++ project and calling JS_NewRuntime()
  • Set memory limits with JS_SetMemoryLimit() to sandbox untrusted scripts
  • Compile scripts to bytecode with qjsc -o app script.js for faster cold starts
  • The quickjs-ng community fork adds CMake support and continuous CI testing

Key Features

  • Full ES2023 compliance verified against the official Test262 suite
  • Tiny footprint suitable for microcontrollers and WebAssembly targets
  • Deterministic memory management via reference counting
  • Fast startup compared to JIT-based engines on short-lived scripts
  • Permissive MIT license allows embedding in commercial products

Comparison with Similar Tools

  • V8 — JIT-compiled, high throughput but large binary and memory footprint; QuickJS is interpreted but tiny
  • SpiderMonkey — Mozilla engine with JIT; QuickJS trades peak speed for minimal size
  • Hermes — Meta engine optimized for React Native; QuickJS covers the full ES spec more completely
  • Duktape — another embeddable engine but targets ES5; QuickJS supports modern ES2023
  • MicroJS (mjs) — extremely minimal; QuickJS offers much broader spec coverage

FAQ

Q: How fast is QuickJS compared to V8? A: QuickJS is an interpreter without JIT, so it is slower on long-running compute. For short scripts and startup-sensitive use cases, the gap narrows.

Q: Can QuickJS run Node.js modules? A: QuickJS supports ES modules but does not include the Node.js standard library. Community projects like txiki.js add Node-compatible APIs.

Q: Is QuickJS suitable for production embedding? A: Yes. Its small size and deterministic GC make it a strong fit for plugin engines in games, databases, and network devices.

Q: What is quickjs-ng? A: A community-maintained fork that adds CMake builds, CI, and incremental improvements while tracking upstream releases.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产