<!-- https://tinyscript.tinyactors.dev/ -->
# tinyscript · JavaScript compiled to WebAssembly

Kind: pitch. For: [Embedder](https://tinyscript.tinyactors.dev/audiences/embedder.xml), [Script author](https://tinyscript.tinyactors.dev/audiences/script-author.xml).
Voice: [Pitch](https://tinyscript.tinyactors.dev/voices/pitch.xml).

> tinyscript compiles JavaScript and TypeScript to standard WebAssembly and runs it inside your application, with fuel, a caller-owned workspace and no ambient I/O.

tinyscript compiles JavaScript and TypeScript to a standard WebAssembly module and runs it with a small interpreter inside your application. Every clock read and message goes through your code.

- **17 of 18** Workloads with fewer instructions than QuickJS ([source](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/bench/RESULTS.md))
- **66.7% fewer** Instructions to clamp a retry deadline ([source](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/bench/RESULTS.md))

[Read the reference](https://tinyscript.tinyactors.dev/reference/index.md) · [See how it works](https://tinyscript.tinyactors.dev/architecture/index.md)

<a id="effects"></a>

## No clock, file or socket of its own

A script that reads the clock or opens a socket inside your engine is a script you can't replay or bound. tinyscript's core has no ambient filesystem, clock, output or random source.

A program asks for each of them as an effect. The interpreter parks the call, and your code replies when it chooses.

- **Effects cross a message boundary**: The runtime parks an invocation on a request and resumes it on a validated reply with the same request number. Source: [tinyscript, `spec/tinyscript.xml`, Effects](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/spec/tinyscript.xml)

<a id="instructions"></a>

## Fewer instructions than QuickJS on 17 workloads

Callgrind counted the instructions each engine retired on the same 18 JavaScript workloads, with identical output required. tinyscript retired fewer than upstream QuickJS on 17 of them.

It lost one: folding byte counts across telemetry batches took 0.1% more.

| Workload | tinyscript | QuickJS | Change |
|---|---|---|---|
| Clamp a retry deadline with `Math.min` and `Math.max` | 31,802,378 | 95,503,891 | 66.7% fewer |
| Dispatch decoded telemetry event tags | 44,218,969 | 105,763,163 | 58.2% fewer |
| Select a delivery policy for each event | 4,991,776 | 9,702,991 | 48.6% fewer |
| Branching reconnect policy | 221,553,748 | 328,454,104 | 32.5% fewer |
| Deduplicate message IDs within each batch | 31,287,525 | 35,740,038 | 12.5% fewer |
| Fold delivered byte counts across telemetry batches | 4,079,393 | 4,074,794 | 0.1% more |

Instructions retired, counted by Callgrind 3.24.0 on an AMD EPYC 9V74 at tinyscript commit `18ad163d`, 4 December 2026, against QuickJS's 2026-06-04 release. Six of the 18 workloads.

- **All 18 workloads, with how to rerun them**: The results list every workload, QuickJS-ng beside upstream QuickJS, and the commands that reproduce the counts. Source: [tinyscript, `bench/RESULTS.md`](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/bench/RESULTS.md)

<a id="bounds"></a>

## Bound each call's time and memory

An engine that allocates as it pleases turns one script's spike into every tenant's outage. tinyscript compiles in a workspace your application supplies, and each call runs in an arena its invocation owns.

The interpreter counts fuel as it runs, so your application decides how long a call may run.

- **Fuel bounds a call**: The interpreter counts fuel, so that an application can bound how long a call may run. Source: [tinyscript, `docs/compiler.md`](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/docs/compiler.md)
- **Memory comes from the caller**: The compiler works in one block of memory the request supplies. An invocation owns an arena, which a tracing collector compacts. Source: [tinyscript, `spec/tinyscript.xml`, Heap and identity](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/spec/tinyscript.xml)

<a id="standard"></a>

## Standard WebAssembly you can inspect

An image is an ordinary WebAssembly module, so standard tools read it. tinyscript's own data, such as source positions and layouts, travels in custom sections that other hosts may ignore.

The command-line tool disassembles an image, and a debug build carries its source text.

- **Custom sections carry the rest**: Sections such as `tinyscript.abi` and `tinyscript.positions` say how exports take values and where each call and throw is in the source. Source: [tinyscript, `docs/compiler.md`](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/docs/compiler.md)

<a id="typescript"></a>

## TypeScript types become layout predictions

tinyscript parses erasable TypeScript itself, with no separate build step. A record type tells the compiler which slot a field is likely in.

The run time checks each prediction, so an object of another shape still works through ordinary lookup.

- **A type is a hint, not a promise**: Reading `session.attempt` on a parameter typed `{ id: number, attempt: number }` tries the second own slot first, and looks the property up normally when the key there differs. Source: [tinyscript, `README.md`](https://github.com/tinyactors-dev/tinyactors/blob/cf16b49be65fe039b38c80ac5631b90cb48bd166/tinyscript/README.md)

<a id="status"></a>

## Every feature with its status

tinyscript compiles a profile of JavaScript, not all of it yet. The reference names each feature as MDN does and says whether it is implemented, partial, planned or excluded.

A construct the compiler has no case for fails with an error that names it, instead of a guess.

[Read the reference](https://tinyscript.tinyactors.dev/reference/index.md) · [Learn the words](https://tinyscript.tinyactors.dev/glossary/index.md)
