Performance
The mean time of six benchmarks, with plain JavaScript, the transform only, and the library.
The benchmarks
The command pnpm bench starts each case in a separate Node.js process. Each process measures each benchmark with tinybench. A value is the mean time of one operation of the benchmark. The command does 5 rounds, with a different order of the cases in each round, and a value is the median of the rounds. The rounds decrease the effect of other work on the machine.
| Benchmark | What it does |
|---|---|
| await loop | One async function with 10,000 await steps. |
| async calls | 10,000 async functions in sequence, each with one await. |
| then chain | A chain of 10,000 then callbacks. |
| concurrent tasks | 1,000 async functions at the same time, each with 10 await steps, in one context. |
| request handlers | 1,000 request handlers, each in its own context, with three await steps and one read of the context. |
| get in nested contexts | 100,000 reads with get(), 5 contexts deep. |
The cases
| Case | What it measures |
|---|---|
| Plain JavaScript | The same code without the library. A Variable class without propagation gives the same API. |
| Transform only | The Babel preset with a plain coroutine. This case shows the cost of the transform without the cost of the context. |
| Library | The Babel preset and the browser runtime. |
The tools wrote this data at 23 Nov 2026, 11:15 UTC.
Node.js v24.22.3, Linux 7.0.0-1020-azure, AMD EPYC 9V74 80-Core Processor. The values come from CI run 45162855713 of 2026-11-23.
The mean time of each benchmark
Show the data as a table
| Benchmark | Case | Mean time | Factor |
|---|---|---|---|
| await loop | Plain JavaScript | 0.44 ms | 1× |
| await loop | Transform only | 0.59 ms | 1.35× |
| await loop | Library | 0.71 ms | 1.63× |
| async calls | Plain JavaScript | 0.87 ms | 1× |
| async calls | Transform only | 1.5 ms | 1.71× |
| async calls | Library | 2.2 ms | 2.51× |
| then chain | Plain JavaScript | 0.27 ms | 1× |
| then chain | Transform only | 0.27 ms | 0.99× |
| then chain | Library | 0.49 ms | 1.82× |
| concurrent tasks | Plain JavaScript | 0.6 ms | 1× |
| concurrent tasks | Transform only | 0.82 ms | 1.38× |
| concurrent tasks | Library | 1.3 ms | 2.23× |
| request handlers | Plain JavaScript | 0.49 ms | 1× |
| request handlers | Transform only | 0.61 ms | 1.24× |
| request handlers | Library | 1.1 ms | 2.27× |
| get in nested contexts | Plain JavaScript | 0.19 ms | 1× |
| get in nested contexts | Transform only | 0.19 ms | 1× |
| get in nested contexts | Library | 0.67 ms | 3.51× |
What the results tell
- The transform. Each async function of transformed code is a generator that the coroutine operates. This costs more than a native async function. The number of microtask steps of each
awaitdoes not change. - The context. Each
thencallback and each step of the coroutine sets the context and sets it again after the step. Eachthencall makes two small wrappers. get(). One read takes only some nanoseconds, and the home page shows the value of the last run. The plain case reads one field, so the factor is large, but the time is small.
Note
The values are microbenchmarks. The benchmarks do no other work, so the factors are the largest possible factors. Measure your own application before and after you add the library.
Size
The command pnpm bench:size builds minified bundles with Vite, and measures them with gzip and brotli. Vite builds each bundle as an application, because a library build of Vite keeps the white space. The bundle of the runtime keeps all exports of async-browser-context and async-browser-context/runtime. The results go to bench/results/size.json.
The tools wrote this data at 23 Nov 2026, 11:15 UTC.
Vite 8.3.8. The values come from CI run 45162855713 of 2026-11-23.
| Code | Minified | gzip | brotli |
|---|---|---|---|
| The runtime: the classes, the patches and the runtime of the transform | 22.6 kB | 7.4 kB | 6.7 kB |
| zone.js 0.16.3, for comparison | 34.7 kB | 11.8 kB | 10.7 kB |
The transform also makes the code of the application larger. The command builds each package of a set of npm packages four times. Each bundle keeps all exports of the package, and does not contain the runtime. The values are gzip sizes.
The tools wrote this data at 23 Nov 2026, 11:15 UTC.
| Package | Async functions | Without the transform | With the Vite plugin | With names: false | Target ES2016, no plugin |
|---|---|---|---|---|---|
| react-dom 19.3.0 | 0 | 67.6 kB | 67.6 kB (+0%) | 67.6 kB (+0%) | 67.7 kB (+0%) |
| @tanstack/query-core 5.104.2 | 8 | 11.4 kB | 11.9 kB (+5.1%) | 11.9 kB (+5%) | 14.5 kB (+27.7%) |
| ky 2.2.0 | 28 | 10.7 kB | 11.2 kB (+4.1%) | 11.0 kB (+2.9%) | 12.5 kB (+16.4%) |
| idb 8.0.4 | 2 | 1.5 kB | 1.6 kB (+7.9%) | 1.6 kB (+7%) | 2.4 kB (+64.4%) |
| @supabase/supabase-js 2.117.3 | 358 | 56.0 kB | 58.6 kB (+4.6%) | 57.6 kB (+2.9%) | 59.5 kB (+6.3%) |
| openai 7.32.0 | 145 | 80.6 kB | 85.6 kB (+6.2%) | 84.9 kB (+5.3%) | 88.5 kB (+9.8%) |
| @aws-sdk/client-s3 3.1149.0 | 214 | 93.4 kB | 96.1 kB (+2.9%) | 95.5 kB (+2.3%) | 99.4 kB (+6.5%) |
| Example application: React DOM, TanStack Query, supabase-js and ky | 394 | 144.5 kB | 147.9 kB (+2.4%) | 146.8 kB (+1.6%) | 151.9 kB (+5.2%) |
With the Vite plugin, the API clients are 2.9 to 6.2 percent larger. The option names: false removes 0.2 to 1.8 percent of each package with async functions. The values come from CI run 45162855713 of 2026-11-23.
- User interface code. React DOM has no async functions, so the transform does not change it. In an application, the code with async functions is usually a small part.
- Code with much async code. The transform adds the most to API clients, as the text under the table tells. Each async function becomes a generator in a function that starts
coroutine. - Small packages with
for await. Babel adds its helper forfor awaitto each module that has such a loop: approximately 0.5 kB with gzip. This is the cause of the large percent of TanStack Query. Since version 0.2.3, the async generators use the driver of the runtime, so the modules do not contain the async generator helper of Babel. - The names. The preset gives the name of each async function to the callback hooks. The option
names: falseremoves the names. - The target ES2016. A compiler with this target also keeps the context through
await, except rule C5 (build tools). The target also changes newer syntax, so the bundles are larger than with the preset.
Browsers
The command pnpm bench:browsers measures await and then in Chromium, Firefox and WebKit with Playwright. One run repeats a workload until a minimum time has passed, and divides the time by the number of repetitions. The text above the table gives this time, the number of steps and the number of runs. Each case has its own page, and the order of the cases changes in each run. "Babel helper" is the async transform of Babel with its own helper, without the library. Many compiled packages use such a helper.
The tools wrote this data at 23 Nov 2026, 11:16 UTC.
Each value is the time of 50,000 steps in ms, as the median of 7 runs. One run repeats the workload until at least 100 ms have passed. The values come from CI run 45162855713 of 2026-11-23.
| Browser | Workload | Native | Babel helper | Library |
|---|---|---|---|---|
| Chromium 158.0.8127.18 | await null | 1.5 | 2 | 2.7 |
| Chromium 158.0.8127.18 | await of a promise | 1.9 | 2.5 | 3 |
| Chromium 158.0.8127.18 | Async generator with for await | 5.5 | 8.8 | 13 |
| Chromium 158.0.8127.18 | then chain | 1.4 | 1.4 | 2.9 |
| Firefox 159.0 | await null | 0.47 | 178 | 2.6 |
| Firefox 159.0 | await of a promise | 0.75 | 142 | 30 |
| Firefox 159.0 | Async generator with for await | 141 | 654 | 475 |
| Firefox 159.0 | then chain | 43 | 40 | 84 |
| WebKit 27.2 | await null | 1.2 | 2.2 | 2.4 |
| WebKit 27.2 | await of a promise | 1.3 | 2 | 2.8 |
| WebKit 27.2 | Async generator with for await | 4.4 | 11 | 12 |
| WebKit 27.2 | then chain | 1.5 | 1.6 | 7.2 |
- Async generators. Since version 0.2.3, the driver of the runtime operates each async generator with a native
await. Before, the helper of Babel was in each module, and each step was athencallback. With version 0.2.2, the async generator workload took 11.2 ms in Chromium, 560 ms in Firefox and 16 ms in WebKit. - The coroutine. Since version 0.2.2, the coroutine operates each async function with a native
await. Before, each step was athencallback, as in the Babel helper. In Firefox, 50,000 awaits ofnulltook 292 ms with version 0.2.1. - Firefox and the patch of
then. Firefox has a fast path forawaitof a promise. A patch ofPromise.prototype.thenstops this fast path, also for code without the transform. Eachawaitof a promise then takes approximately 0.8 µs more. zone.js also patches the promises, so it has the same cost. - Playwright and Firefox. Playwright controls Firefox with the debugger API. Firefox then records an async stack for each
thencallback. Thus,thencallbacks take more time in this measurement than in a Firefox without Playwright. With the preferencejavascript.options.asyncstackset tofalse, a chain of steps inthencallbacks was 7 times faster.