A Go module that embeds the QuickJS-NG WASI WebAssembly runtime.
This repository provides the command model WASM binary, where QuickJS runs to completion in _start(). If you need re-entrant execution with host-controlled scheduling (for browsers, Node.js, Deno, or event-loop integration), see the reactor model variant:
- go-quickjs-wasi-reactor - Exports
qjs_init(),qjs_eval(),qjs_loop_once()for non-blocking execution
QuickJS is a small and embeddable JavaScript engine. It aims to support the latest ECMAScript specification.
This project uses QuickJS-NG which is a fork of the original QuickJS project by Fabrice Bellard and Charlie Gordon, after it went dormant, with the intent of reigniting its development.
This module provides easy access to the QuickJS-NG JavaScript engine compiled to WebAssembly with WASI support. The WASM binary is embedded directly in the Go module, making it easy to use QuickJS in Go applications without external dependencies.
- Embeds the latest QuickJS-NG WASI WebAssembly binary
- Provides version information about the embedded QuickJS release
- Automatic update script to fetch the latest QuickJS-NG release
package main
import (
"fmt"
"github.com/paralin/go-quickjs-wasi"
)
func main() {
// Access the embedded WASM binary
wasmBytes := quickjswasi.QuickJSWASM
fmt.Printf("QuickJS WASM size: %d bytes\n", len(wasmBytes))
// Get version information
fmt.Printf("QuickJS version: %s\n", quickjswasi.Version)
fmt.Printf("Download URL: %s\n", quickjswasi.DownloadURL)
}A complete example interactive JS REPL is provided in the ./wazero-quickjs directory.
This demonstrates how to run QuickJS in a Wazero WebAssembly runtime.
To run the REPL:
cd ./wazero-quickjs && go run ./This will start an interactive JavaScript shell powered by QuickJS-NG.
To install the repl run in your home directory:
go install github.com/paralin/go-quickjs-wasi/wazero-quickjs@masterThe wazero-quickjs command will now run the wazero repl.
To update to the latest QuickJS-NG release:
./update-quickjs.bashThis script will:
- Fetch the latest release information from the QuickJS-NG GitHub repository
- Download the
qjs-wasi.wasmfile - Generate version information constants
go testThis module is released under the same license as the embedded QuickJS-NG project.
MIT