Skip to content

elsaland/elsa-next

Repository files navigation

elsa-next

Small, baseline performant JavaScript runtime.

If you want to answer, how fast can JavaScript runtimes go? This is the place.

Elsa is "engine-agnostic". It has engine backends for:

  • V8
  • JavaScriptCore
  • SpiderMonkey
  • QuickJS
  • Hermes

TypeScript stripping support available behind typescript feature flag using swc. Typechecking done using stc.

Why?

When it first started out, Elsa was a fun project written in Go.

I was using just-js/spindle/crimson for baseline perf comparison when working on Deno. I wanted to benchmark against many many possibilities. Elsa is an attempt to write a cross-platform engine-agnostic fast JavaScript runtime.

Elsa is designed for:

  • Speed.

  • Size. Smallest configuration is 0.3MB.

  • Tons of compile time feature flags. Don't include things in the binary you don't need!

    Ex: "I want to run a script in V8 that only uses FS apis, also don't want to type check but strip types":

    cargo build --no-default-features --features "use_v8,fs,typescript"

  • Easy to embed. Offers a Rust crate and C API (TODO).

Elsa is a hobby project. It does not intend to compete with major runtime.

Building

To build Elsa, you need:

  • Deno (>=1.28.3)
  • Rust (>=1.66.0)
./build.ts debug # build debug. V8 without typescript support.
./build.ts release # build release.
./build.ts release-all # build release with all engine backends.

./build.ts release --features "use_quickjs,typescript,typecheck" # build release with quickjs and full TS support.
# ...

You need python 3.9 (not 3.10) to build the spidermonkey backend.

# Warning: this may be destructive!
brew install [email protected]
cd $(dirname $(which python3.9))
rm -f python3 pip3
ln -s python3.9 python3
ln -s pip3.9 pip3

Size

  • Note: jsc is not bundled but linked dynamically. This will change in the future and included it in the below table.

Without typescript support:

┌───────┬───────────┬───────────┐
│ (idx) │ feature   │ size      │
├───────┼───────────┼───────────┤
│     0 │ "v8"      │ "26.94MB" │
│     2 │ "quickjs" │ "1.28MB"  │
└───────┴───────────┴───────────┘

With typescript support:

┌───────┬───────────┬───────────┐
│ (idx) │ feature   │ size      │
├───────┼───────────┼───────────┤
│     0 │ "v8"      │ "31.96MB" │
│     2 │ "quickjs" │ "6.30MB"  │
└───────┴───────────┴───────────┘

Guidelines for contributors

Feel free to reach out if you are interested in contributing.

  • No serde. It's a performance killer. Serializing objects is discouraged. If you need to pass untyped complex data, use the engine's Value type.
  • Typed data must always have inlined conversions using codegen in place.
  • Everything should be behind a compile time feature flag.

License

MIT