Repository navigation
faster, lighter, benchmarked
Bau.js is faster and lighter, and a new benchmark example compares it with Vanilla JS, Svelte, Vue, Angular and React on js-framework-benchmark's operations.
Bau.js
Faster
- Partial update of a loop: several items changed in one update are now updated once each, and the children are walked once, in order. Before, each change looked its element up again, which was quadratic in the number of changes. (#200)
- Select row: an attribute bound to a state is written on the first render, then only when its value changes. A class bound to a state shared by many elements, such as the selected row, is no longer rewritten on all of them. (#201)
- Element creation: plain objects and functions are recognized without building strings, and settable props are cached by tag. Static props and event handlers are set directly, and
autofocusis only checked when a prop is named so. (#203) - Clear rows: bindings are cleaned up after the paint of the next frame, not before it, without an array per state. (#204)
- Swap rows: items set by index with the length unchanged now move or render only the elements at those indexes. (#206)
Less memory
- States are instances of a
Stateclass, so theirvalaccessors are shared on the prototype instead of two closures per state. (#206) - A binding keeps its first state in a field and only creates a
Setfrom the second one. The sets that track the states a render reads are reused. (#206) - The bindings of removed elements are now released even when nothing else changes. Before, clearing a list and then doing nothing kept its rows in memory. (#199)
Smaller
- 8,984 → 8,596 bytes minified, 4,079 → 3,982 gzip, at the same speed. (#211)
Behavior changes
- A bound attribute set to
nullorundefinedis removed. It was set to the text"null"or"undefined". It now behaves like a static prop: no attribute on the first render, removed when the value becomesnullorundefined, and set again afterwards. (#210) - A state set to
undefinedstill reads its initial value, as in earlier versions. (#206)
Benchmark example
examples/benchmark reproduces js-framework-benchmark's CPU, memory and start-up benchmarks, without depending on it. It also compares the size of each framework and the code of each implementation, and writes an HTML report: pnpm bench. (#196, #198, #205, #207, #208, #209, #212, #213, #214)
- Implementations: Vanilla JS, Bau.js, Svelte 5, Vue 3, Angular 22 and React 19, the keyed implementations of js-framework-benchmark. The e2e tests check that each one works and is keyed.
- Report: a summary table plus a table per category. Click a framework to compare the others to it.
Compared with Bau.js, on an Apple M2 with Chromium 159, 3 iterations:
| Vanilla JS | Svelte | Vue | Angular | React | |
|---|---|---|---|---|---|
| CPU | −9% | +6% | +7% | +43% | +50% |
| memory | −23% | +31% | +52% | +42% | +75% |
| start-up | −34% | +34% | +78% | +149% | +197% |
| size (gzip) | −74% | +197% | +394% | +619% | +1166% |
| code | +11% | −10% | +6% | +13% | +7% |
Full changelog: v0.204.0...v0.300.0