Skip to content
liustackPublic

About

The fastest pure Go JavaScript engine for rendering React.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

23 stars

Watchers

0 watching

Forks

Latest commit

 

History

4,742 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

liustack/slowjs

The fastest pure Go JavaScript engine for rendering React.

简体中文 · How fast · API · Benchmarks · Changelog

Follow @liustack on X Go reference Go version CGO off License Not backed by Y Combinator Users unknown

Your Go server renders React pages itself, faster than C QuickJS on the same code, in one static binary with no cgo and no Node process beside it.

It is for Go programs that need to run JavaScript, such as rendering React on the server. The engine runs ES2023 with modules, async generators, proxies, BigInt, and Intl in every Chromium locale and Temporal, both built in. It is QuickJS compiled to Go assembly and tuned for server rendering, built for tifa, a Go framework for React pages.

It is an engine, not Node: there is no require, fs or process. Code from npm runs unchanged once it is bundled as for a browser, as React is.

How fast

CPU time of one render of the server bundles of tifa's apps, on one core, as a multiple of liustack/slowjs (lower is faster):

Engine Pure Go React bench pages MUI pages Shop pages
liustack/slowjs yes 1.00 1.00 1.00
liustack/slowjs, on polyfills yes 0.96 1.71 1.54
moejs yes 1.53 1.41 1.73
go-quickjs yes 2.58 3.04 3.82
C QuickJS 2026-06-04 no, C 1.93 3.39 2.20
Hermes V1 no, C++ 1.20 1.87 1.92
Node 24 --jitless no, C++ 0.87 1.33 0.87

Measured on v0.31.2 on a GCP t2d-standard-4 (AMD EPYC 7B13), Go 1.27.4. The comparison is among interpreters: go-quickjs runs with its JIT off, as it comes, Hermes runs hermesc -O bytecode and Node runs with --jitless. Every engine runs as it comes, on its own Intl where it has one and on the FormatJS polyfill where it has none (C QuickJS and Hermes). The second row is liustack/slowjs without its built-in Intl, URL and Temporal, on the same polyfills as C QuickJS and Hermes: it shows how much of the lead on the MUI and shop pages comes from the interpreter and how much from Intl written in Go. The bench pages need no Intl, so that column is the same JavaScript on every engine.

It is not the fastest on everything: on the V8 benchmark suite Hermes and Node score higher.

Engine Pure Go V8 suite score
Node 24 --jitless no, C++ 1875
Hermes V1 no, C++ 1696
liustack/slowjs yes 1546
moejs yes 1405
go-quickjs yes 1303
C QuickJS 2026-06-04 no, C 1056

It scores 1.49 times C QuickJS, 1.18 times go-quickjs and 1.11 times moejs, though in some rounds moejs and it cannot be told apart. go-quickjs leads on the RegExp benchmark, moejs on Richards and NavierStokes.

docs/benchmarks.md has both tables in full, what each engine was given to run, and how to run it all again.

Install

go get github.com/liustack/slowjs

Go 1.26.6 or later, up to Go 1.27. No cgo and no C compiler: it builds with CGO_ENABLED=0 and cross-compiles like any Go code. The Go assembly of the engine was checked against every patch release from Go 1.26.6 to 1.27.4, and a new patch release is checked every week. It leans on how Go starts a function and handles a fault, so a newer Go stops the build until liustack/slowjs has been checked with it and moves its limit in a patch release. -tags slowjs_anygo builds anyway (see Moving to a newer Go).

Platforms

linux and darwin, on amd64 and arm64, and windows/amd64. A build for any other target stops with an error that names them.

A first VM

package main

import (
	"errors"
	"fmt"
	"time"

	"github.com/liustack/slowjs"
	"github.com/liustack/slowjs/intl"
)

func main() {
	vm, err := slowjs.NewVM()
	if err != nil {
		panic(err)
	}
	defer vm.Close()

	vm.SetMemoryLimit(64 << 20) // 64 MiB for this VM
	if err := vm.SetEvalTimeout(100 * time.Millisecond); err != nil {
		panic(err)
	}
	if err := intl.Register(vm); err != nil {
		panic(err)
	}

	v, err := vm.Eval(`new Date(0).toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai'})`, slowjs.EvalGlobal)
	fmt.Println(v, err) // 1970/1/1 08:00:00 <nil>

	_, err = vm.Eval(`try { for (;;) {} } catch (e) { 'caught' }`, slowjs.EvalGlobal)
	var e *slowjs.Error
	if errors.As(err, &e) && e.Interrupted {
		fmt.Println("timed out, and no catch saw it")
	}
}

A VM is not safe for several goroutines at once: give each goroutine its own, or keep a pool. Intl and Temporal use embedded tz 2026e, so they need no host zoneinfo.

Beyond Eval and Call, the API has Go functions that JavaScript calls as built-ins, control of the GC and the memory of a VM, a clock per VM, Temporal, and parts of React's server renderer written in C. docs/api.md lists them, and pkg.go.dev documents each.

What changes for you

  • A limit ends the call. A script that runs past its eval timeout or its memory limit stops there, whatever it catches: no catch, finally, promise handler or Go function of the page gets to run on. *Error says whether it was a timeout or memory. A panic in a Go function you gave the VM comes back to your Go code, and a VM that ran out of memory still closes without a leak.
  • The same page on every machine. A script's local time is UTC in every VM, without setting TZ for the whole process. Intl formats in every locale Chromium has, compared with Chromium 156 on about 75,000 expressions.
  • Strings arrive whole. A Go string from JavaScript is always valid UTF-8, and a Go string with invalid bytes reads in JavaScript as Go itself decodes it.
  • Faster than C, without C. The changes of liustack/slowjs to the C of QuickJS make up for more than what compiling it to Go assembly costs (see the table above). Several VMs on several cores do not wait on one lock.

Why you can trust it

  • The engine is upstream QuickJS. engine/ is Bellard's C at one pinned commit, with the changes of liustack/slowjs on top, each written down. LLVM compiles it to Go assembly that is checked in, so building needs no C compiler, and make check-gen fails when the checked-in files are not what the generator makes from engine/ (how to check).
  • The generator refuses what it has not checked. It stops on an instruction, a call or a stack frame it has no rule for, and checks the linked code of a test binary, so a change of the C or of Go itself that breaks the engine shows up as a failed build or test, not as a wrong answer.
  • Every change is written down. docs/changes gives each change with why it is safe, what it costs in memory, what it gains on which machine, and its tests.
  • The tests are upstream's and more. test262 gives 33 known failures, 25 fewer since the fixes taken from upstream QuickJS, and the same ones from run to run. On top come the recorded outputs of the engine, checks in C under AddressSanitizer and UndefinedBehaviorSanitizer, and the Go tests of the API.
  • Someone depends on it. It is kept for tifa, a Go framework that renders React pages in it, and each release is measured on tifa's pages before tifa takes it.

Documentation

Doc Read it when
API You want the Go API beyond Eval and Call
Changes You want to know why each change to the engine is safe, what it costs and what it gains
Performance You want to know how fast each release renders, or what was tried
Benchmarks You want to know how this engine compares with the other pure Go JavaScript engines
Changelog You are upgrading and want to know what changed
Architecture You are about to change the code
Testing You are about to commit, or want to check the engine
Upgrading You are taking a commit of upstream QuickJS, new locale data or a newer Go
Releasing, Commits You are making a release or a commit
Upstream You are moving from modernc.org/quickjs or github.com/liustack/quickjs (v0.30.0 to v0.30.7), or want to know where the code comes from
History You want the numbers of the engine before v0.29, QuickJS translated to Go by ccgo

Where it comes from

The engine is QuickJS by Fabrice Bellard and Charlie Gordon, the release of 2026-06-04. docs/upstream.md has the exact version, how new QuickJS commits are taken in, and what to expect when you move from modernc.org/quickjs.

Thanks to Fabrice Bellard and Charlie Gordon for QuickJS, and to Jan Mercl, Dan Kortschak and the other authors of modernc.org/quickjs and modernc.org/libquickjs. Their work showed that QuickJS can run inside a pure Go program, and it inspired liustack/slowjs.

Community

Issues are welcome any time: open one. Tell us what you run in it, where it is slow, and what should come next. Follow the liustack WeChat official account, and come find me on X: @liustack. What changes in liustack/slowjs and tifa is shared on WeChat and X.

The liustack WeChat official account: AI startup opportunities, indie-dev insights, and hands-on AI tooling, delivered as they happen. Scan the QR code in WeChat, or search for "liustack":

liustack WeChat official account

Contributing

liustack/slowjs does not accept pull requests. One maintainer reviews and owns every line, on purpose, so the engine stays dependable. Two ways that help:

  • Open an issue. A wrong answer, a slow render, a limit that did not hold, an unclear doc. Issues are read and decide what gets built next.
  • Fork it. Your copy is yours to change and publish.

A security problem goes in a private report, as SECURITY.md says. CONTRIBUTING.md has the rest.

License

The files liustack/slowjs created are under the MIT license. Code that came from other projects keeps its own license: the C of QuickJS, what remains from modernc.org/quickjs, the TLSF allocator, musl's libc functions and the locale data of intl and go-intl. The gopher of the banner is drawn after the Go gopher by Renée French (CC BY 4.0). NOTICE.md says which license covers which path, and which notices a program that ships this module has to carry.

About

The fastest pure Go JavaScript engine for rendering React.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

23 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages