A pure Go implementation of ECMAScript 5.1+ with a focus on standard compliance and performance.
Goja is a JavaScript engine implemented in pure Go that executes ECMAScript 5.1+ code. It allows developers to embed JavaScript runtime capabilities directly into Go applications, facilitating scripting, configuration, or dynamic behavior without relying on external engines like V8. It solves the need for a lightweight, standard-compliant JavaScript interpreter that integrates natively with Go's ecosystem and avoids cgo overhead.
Go developers who need to embed JavaScript scripting within their applications, such as for plugins, rules engines, or dynamic configuration, and researchers requiring fine-grained control over execution environments.
Developers choose Goja for its pure Go implementation, which eliminates cgo dependencies and simplifies building and deployment across platforms. It offers better performance than many other Go-based JavaScript interpreters and provides deep, low-level control over the runtime, making it ideal for scenarios where frequent Go-JavaScript interop is needed.
ECMAScript/JavaScript engine in pure Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Eliminates cgo dependencies, making it easy to build and deploy across all Go-supported platforms, as highlighted in the FAQ for avoiding V8's complexity.
Passes nearly all tc39 test262 tests for implemented features, ensuring reliable adherence to ECMAScript specifications, which is a core project goal.
Provides methods like ToValue and ExportTo for efficient data exchange between Go and JavaScript, with customizable field name mapping for natural JS access.
Includes vm.Interrupt() for halting scripts and supports source maps for debugging, offering fine-grained runtime management useful for research.
ES6 features are still a work in progress with known gaps, and incompatibilities exist for WeakMap, WeakRef, Date, and JSON parsing due to Go runtime limitations.
While faster than otto, it is not as performant as V8 for compute-intensive JavaScript, limiting its use in heavy workloads, as admitted in the FAQ.
Runtime instances are not goroutine-safe, restricting usage in concurrent Go applications without careful management or multiple runtime instances.