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
qjsinterpreter and aqjscbytecode 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
makeon any POSIX system or use CMake for cross-compilation - Embed by linking
quickjs.cinto your C or C++ project and callingJS_NewRuntime() - Set memory limits with
JS_SetMemoryLimit()to sandbox untrusted scripts - Compile scripts to bytecode with
qjsc -o app script.jsfor faster cold starts - The
quickjs-ngcommunity 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.