Repository navigation
Description
Goal
Make Octane's client runtime smaller without changing its public API.
Same production app, same minifier settings (oxc, then swc), gzip:
| Size | |
|---|---|
Preact + hooks + preact/compat + signals core |
11.4 kB |
| React + react-dom | 59.4 kB |
| Octane, what that app ships | 133.4 kB |
The bundle-size benchmark shows the same picture: Octane's full client runtime is about 173–179 kB gzip there. Small demo apps look fine (the rows demo is 38 kB), because unused features get tree-shaken out. Real apps that use hydration, Suspense, transitions, view transitions, forms and signals end up close to the full size.
Not the cause: development-only code is already stripped from production builds, error text is under 300 bytes, and a stronger minifier gives about 11% at most (for every framework equally).
Questions
The size mostly comes from a few design choices. Each one needs a decision before work can start.
1. Should Octane render off-screen and commit, like React?
Octane writes to the real DOM while rendering. To support transitions that get abandoned, it records every write so it can undo it, and that logic is spread across hundreds of places. React renders into a separate in-memory tree and simply throws it away, which costs no extra code. This is the largest structural cost.
Question: is changing this on the table (a big rewrite, and the speed trade-offs need measuring), or should we treat it as a fixed floor and optimise around it?
2. Can size budgets require an equal removal?
Several recent PRs exist only to raise size budgets (#1793, #1794, #1797, #1806).
Question: can we adopt a rule that a size increase must be offset by an equal removal, unless a maintainer explicitly approves the feature it pays for?
3. Can the near-identical fast-path copies be merged?
Many functions exist in several versions for speed, for example hookMemoPublish0 through hookMemoPublish4, or componentSlotLite/Impl/Void.
Question: may I merge copies where benchmarks show no measurable slowdown? I'll post numbers per pair before changing anything.
4. Should signals have a size budget?
Signals are about 20 kB gzip in this app, versus about 1.6 kB for Preact's signals core. Some of that is real extra capability (async data, server seeding).
Question: is there a target size for the signals runtime, and are any of its features candidates for a separate import?
5. Small design calls that unlock small savings
| Idea | Saving (gzip) | Decision needed |
|---|---|---|
| Skip signal checks in apps without signals | about 540 B | Should passing RootOptions.signalOwner switch the signal machinery on? Today any root may receive it, so every app keeps the checks. |
| Restore server signal values only in apps that use signals | 485 B – 1.5 kB in hydrating apps | If the first page using signals is lazy-loaded after hydration starts, it would lose its server values. Fix by having the compiler mark entry points that read signals, or by keeping the raw seed text for the signals engine to read later. |
| Make transition undo, focus preservation and portal events opt-in | about 7 kB, 4.5 kB and 1.7 kB minified | Every root keeps them because any update could be a transition. An opt-in would be an API change. |
In progress, no decision needed
- Optional features mixed into core render code. Signals, view transitions, hydration and transition undo are
ifbranches inside the same functions, so every app pays for all of them. The fix is to let each feature pass in its own code, so it only ships when used. I'm applying that one feature at a time, each checked against the performance benchmarks.- perf(octane): stop bundling FragmentInstance for Activity-only consumers #1802: apps using
<Activity>without Fragment refs stop shipping Fragment ref code (−2.2 kB gzip for those apps) - perf(octane): stop shipping Suspense in hydrating bundles without Suspense #1803: apps that hydrate without Suspense stop shipping Suspense (−8.9 kB gzip, −16%)
- perf(octane): stop bundling FragmentInstance for Activity-only consumers #1802: apps using
- Hydration. Octane checks for mismatches at over 100 spots in its render functions. React instead re-renders the whole boundary. Octane's hydration code is about 5x React's.
- fix(octane): handle hydration mismatches like React 19 (boundary/root client-render fallback) #1784 moves Octane to React's approach (about −15 kB minified)
- Once fix(octane): handle hydration mismatches like React 19 (boundary/root client-render fallback) #1784 lands: about 1–1.5 kB more from unused methods in the hydration class
- Measuring.
- ci(bench): measure bundle sizes with Vite 8's default minifier #1792: measure with Vite's default minifier
Ruled out
| Idea | Why |
|---|---|
Move setHTML's hydration code into the hydration class (#1785) |
Saves 250 B in client-only apps but adds 210–270 B to every hydrating app |
Skip Fragment ref code in createRoot |
createElement(Fragment, { ref }) is public API and needs it |
One helper for the 907 STAGED_DOM?.view(x) ?? x wrappers |
About 100 B, and it adds a function call to most DOM writes |
| Share duplicated code between functions | Gzip already compresses repeats; the best case measured was −81 B |
| Shorten internal property names | About 3% |
How to read the numbers
- Demo app size: what one benchmark app ships after tree-shaking.
- Full size: everything Octane exports, with nothing tree-shaken. Only making the code itself smaller lowers it.
- Runtime only; the compiler isn't included.
- Don't compare gzip with brotli. Brotli is about 16% smaller on the same code.
Activity
trueadm commentedon Oct 6, 2026
I measured each question on current main,
ed57b1ea52. #1784, #1792, #1802 and #1803 have all merged since the issue was opened.Headline:
childSlotrenderer, a one-step cliff of about 33 kB gzip.How it was measured:
benchmarks/bundle-size/run.mjs. On main: rows 33,866; todo 36,788; ceiling 168,939.<Hydrate>takes it to 151,886 B, which is close to the 133 kB app in the issue.benchmarks/js-framework/pair.mjsagainst main, for both the.tsrxand the.tsxrows apps. It reports exact production call counts and DOM mutation counts from jitless Chromium, plus paired wall time over 30 pairs with a 95% interval. Wall time only counts as faster or slower outside ±3%.Q1: render off-screen and commit, like React?
Recommendation: keep rendering in place, but make the journal cheaper.
Bytes, by knockout (the knockouts break the feature; they are upper bounds):
STAGED_DOMwrappers +DOMStage(ViewTransition staging)beginRootRenderin the drain loop), so writes are journaled on ordinary synchronous updates too.Runtime: the journal is the biggest per-update cost. Turning it off for urgent renders, measured on a quiet machine:
.tsrxwall.tsxwall.tsrxcallsDOM mutation counts are unchanged, apart from +4 on replace. Behind these numbers:
Why an off-screen rewrite is not the fix:
DOMStage, used for ViewTransition, and it alone is 5.3 kB gzip. Deferred deletion, effect capture and keyed-list snapshots make up about two thirds of the journal, and any design that can abandon a render needs them.Why reachability gating doesn't work: dropping the journal from apps that import no Suspense API is not sound. A thrown promise in any component, or a promise rendered as a child, can suspend a root, and both live on paths every app reaches.
Sound improvements that change no behavior:
Maintainer call: treating a suspension at an unprotected root, in an app that imports no Suspense API, as an error would save about 4.9 kB on rows plus the runtime above. That is an API divergence. The root journal was previously kept always on by choice.
Q2: should a size increase require an equal removal?
The data argues for a different rule.
query$owner fixes (ci(bench): raise byte budgets for the children signal owner fix #1773, ci(bench): raise byte budgets for pending query owner retirement #1782, ci(bench): raise byte budgets for the pending query owner fix on top of #1761 #1793, ci(bench): raise byte budgets for the children and Hydrate signal owner fix #1797), and rows uses neither. For example, rows now shipspruneSignalRetryVisit, thequery$retry pruning from fix(octane): abort pending queries whose owner a retried attempt replaces #1783, throughrenderBlock.Proposed rule:
Q3: can the near-identical fast-path copies be merged?
Mostly no. Gzip already absorbs the duplication, and the copies exist for measured reasons.
hookMemoPublish0..4benchmarks/baselines/ratios.json; 4–11% slower on missesmemoTake/puTake/nativePuTake0..4evt*ushared tailcomponentSlotVoidintocomponentSlotcomponentSlotLitebag0..16The one worthwhile merge is an exact duplicate:
hydrationMarkerMultiplicityappears in bothruntime.tsandstream-protocol.ts. The two copies sit more than 32 KB apart, outside gzip's window, so merging saves 140–191 B in hydrating apps at zero runtime cost.Q4: should signals have a size budget?
Yes. Proposed targets are listed after the breakdown.
Kitchen-sink breakdown:
signal$/derived$<Hydrate>only, no signals<Hydrate>costs more than signals do: +30 kB in acreateRootapp, because it pulls in the hydration capability.signal$+derived$) costs +12.6–14.5 kB. Built the same way,@preact/signals-coreis 1.63 kB and alien-signals is 1.55 kB.Proposed targets:
createScopekeeps the full surface: −2.2 kB, measured by knockout. A module-level declaration path would save about 1.3 kB (estimated).query$at ≤4 kB marginal, about where it is now.A Preact-sized ~1.6 kB isn't realistic with owner scoping, tracked reads during render, server adoption and transitions.
Q5: the small design calls
Signal checks in apps without signals: worth 1.8–3.75 kB, not 540 B.
renderOwner?.signalOwnerchecks remain, andchildSlotactivates signal bindings whenever it sees a handle.RootOptions.signalOwnercan't remove the code. A check reached fromcreateRootkeeps the activation in the bundle.hydration-flag.ts, set only where owners or handles are created.pair.mjscall counts are strictly lower on every operation.Restoring server signal values only in apps that use signals: keep the raw seed text. Capture and remove the sidecar unconditionally, and parse it from the signals side on first use, which is what
<Hydrate>already does.hydrateRoottime that a route loaded later will read signals.Transition undo: this is the swap driver from Q1, and it already ships only where it's used.
Focus preservation can't be gated soundly.
document.activeElement.tabindexandcontenteditableimperatively.dangerouslySetInnerHTMLanddelegatesFocuscreate focusable elements the compiler can't see.Only the ViewTransition-only staged move can be gated (−187 B). That branch is covered only by a browser test.
Portal events can be gated soundly, and so can four other features. Each is switched on by the only code that creates its state:
queueRefAttach/queueRefDetach)enqueueEffect)armControlledBase)renderPortalState)delegateCaptureEvents)With all six combined, the full
octaneandoctane-prodsuites pass: 1,476 files, 42,719 tests.Stacked: what lands with no API change
The six gates, the signal flags and the marker duplicate merge, stacked:
pair.mjscall counts are strictly lower on every operation (−3 or −4), DOM mutation counts are identical, and wall time is within ±3% everywhere.Not in the issue: the
childSlotcliffAny generic renderable hole pulls in the descriptor renderer, about 33 kB gzip at once. That means a bare
{count},{children},c && <p/>, JSX stored in a variable, or.mapin.tsx..tsrxapp goes from 26,714 to 60,201 B with one bare hole..tsxvs 33,866 B in.tsrx.Fixes:
.tsxroots never specialize.packages/octane/src/compiler/vite.js:420). Vite's TypeScript transform reprints every.tsxfile after Octane, so that check always fails..tsxcomponent that already compiles to a template, rendered by a root: 61,650 → 29,407 B (−32.2 kB). Low risk; tests pass.createElement,createElementAtandcloneElementinstall both.action/formAction, a Fragmentref, or a spread..tsx: 62,427 → 55,991 B (−6.4 kB); any app that reacheschildSlotsaves the same. Rows.tsrxand todo are unchanged; the kitchen sink pays +60 B and the ceiling +106 B.pair.mjscounters unchanged)..tsxcomponent's single trailingreturn <jsx/>to a template (experimental).childSlot..tsxrows app: update −44%, select −68%, swap −56%, remove −67%, select_lots −69% wall time; calls on update −63% and on swap −77%.defaultPropsobservation, HMR and Strong-mode wrappers, and hydration under a value-position ViewTransition. It needs real work.{c && <jsx/>}to an@if. Not prototyped; estimated −31 kB where it is the only retainer.Baselines from #1668 show
.tsxrunning 3× slower than.tsrxon select and 10.5× on select_lots. The "~1.0 ratio" note inbenchmarks/js-framework/README.mdis out of date.Open for a maintainer
Ready to become PRs, none of which changes the API:
.tsxroot proof)Measured but not yet prototyped:
perf(octane): install descriptor form actions and Fragment refs only …
fix(compiler): prove void .tsx components after Vite's TypeScript rep…
perf(octane): record only the relinked rows when a keyed list may rol…
perf(octane): skip undo entries for writes into rows the render creat…
o-alexandrov commentedon Oct 12, 2026
@trueadm I think you should have closed it "Closed as not planned", because the bundle size is still the same issue when using the whole client API.
The whole client API actually grew by 0.1% in current state of
mainbranch comparing to the date when this issue was openedtrueadm commentedon Oct 12, 2026
If you want to try and get the bundle size down more please go for it. I did a bunch of savings already and in most apps that don't use everything the gzip size is better than React when using Vite in my testing. I've been focusing on performance and correctness too so we can't regress there. Maybe if you could add another example app to the apps that demonstrates your issue more. It's not a fair apples to apples to compare Octane with React when using signals. Adding alien-signals to React is more fair