tuturuuu.com/<app>) through the apex
gateway. Theme changes and app switches should feel instant: the theme is a
class swap with no request, and the shared shell (sidebar, top bar, account
menu) stays stable between apps. This page holds the benchmark that checks
this and the numbers each optimization is measured against.
Running the benchmark
The benchmark is read-only. It signs in as a QA user and never writes data, apart from closing first-run dialogs in that QA user’s own workspace.BENCH_APPS (cold loads) and BENCH_SWITCH (the app-switch sequence)
override the default app lists. Point the origin at a staged 0% Worker
version or a local production build to measure a change before promotion. Do
not run the benchmark against a dev server, because dev bundles skew every
number.
The benchmark measures:
Baseline (2026-11-25, production)
Chromium headless, 1440×900, from Vietnam, signed in as a Pro staff QA user. These are medians of 3 samples. Live production varies by about ±30%, so compare a change with a run taken at the same time and place.Theme toggle
The class swap itself was already cheap. It caused no request, no reload, no
React remount and no layout shift. The theme also already follows the user
across apps, because every app on the shared origin reads the same
theme
localStorage key and next-themes syncs other tabs through the storage event.
The switch still looked slow, because every element with transition-colors
or transition-all animated to the new palette for 300-500 ms.
next-themes’ disableTransitionOnChange does not fix this in Chromium. It
calls getComputedStyle(document.body) without reading a property, which does
not flush styles, so transitions still start. Injecting that exact sequence on
production left all 92-1403 transitions running.
App-to-app switch (warm context)
CLS was 0 for every navigation. Every switch is a full document navigation.
None of the pages has Speculation Rules, and every HTML response is
Cache-Control: private, no-store, which also blocks the back/forward cache
(MainResourceHasCacheControlNoStore,
JsNetworkRequestReceivedCacheControlNoStoreResource).
Cold load (empty cache)
Chunk reuse across apps
This was measured over 610 distinct scripts from the eight cold loads.- About 2.5 MB is identical content under the same URL. That is the
/_f/dashboardchunks shared by the web-hosted surfaces (dashboard, Drive, Chat). - Only 106 KB is identical content under different URLs. Each satellite
(
/mail/assets,/calendar/assets,/tasks/assets,/finance/assets,/meet/assets) bundles its own copy of React,@tuturuuu/uiand vendor code, with different chunk boundaries and hashes. Serving the same files from one shared path does not fix this on its own. The satellites first need one shared build of the common packages. - About 32 MB is app-unique, so a user’s first visit to each satellite re-downloads 0.7-2.6 MB of JS.
Ranked opportunities
- Server time (TTFB 1.4-6.2 s on satellites, including revisits). This is the largest cost of every app switch. Tasks spends about 5-6 s before the first byte. Profile the per-request session and workspace resolution and the Supabase round trips in the satellite Workers. Cache the shell data (user, workspaces, apps list) with stale-while-revalidate.
- Per-app vendor and UI bundles (0.7-2.6 MB per first visit). Share one
build of React and
@tuturuuu/uiacross satellites behind one immutable path, or prefetch the next app’s entry chunks. - Cross-app navigation. Add Speculation Rules (
prefetch, thenprerenderfor sidebar app links) and cross-document View Transitions for the shell. Restore back/forward cache eligibility whereno-storeis not needed for safety. - Theme swap animation (300-500 ms). Fixed by
InstantThemeSwapbelow.
Theme switching contract
Every app’s theme provider spreadstuturuuuThemeProviderProps from
@tuturuuu/ui/custom/theme-provider-preset and renders
<InstantThemeSwap nonce={nonce} /> from @tuturuuu/ui/custom/instant-theme-swap
inside it. This covers the shared satellite providers (providers.tsx,
public-providers.tsx), web, workspace, Mail, Calendar, Tasks, Meet,
Mastermind, Chat, Contacts, Forms, Learn, Mind, Nova, Pay, Teach, Colab and
the native apps shell.
The guard watches the light/dark class on <html> and acts before the next
frame, whether the change comes from the menu, another tab or the OS
preference. It flushes styles once while transitions are disabled, so the new
colors become the starting values and nothing animates. Per the CSS
Transitions spec, the flush also cancels any transition already in flight,
such as a sidebar collapse, which jumps to its end state at the moment of the
switch. The injected rule carries the request CSP nonce.
The guard was measured by injecting it into the current production pages (the
numbers for the shipped build follow once it deploys):
Regression coverage:
apps/web/e2e/theme-switch.noauth.spec.tsdrives the swap through the cross-tabstoragepath. It asserts no main-frame document request, CLS 0, no color transitions, and the class applied within 250 ms of the event landing. It is read-only. The web e2e global setup accepts only local origins, so to check a deployed origin (production or a 0% Worker version), run the file with a Playwright config that dropsglobalSetupand setsBASE_URL. Subframes such as the Turnstile widget may re-theme themselves and are excluded.packages/ui/src/components/ui/custom/instant-theme-swap.test.tsxandtheme-provider-preset.test.tsxpin the guard and the shared options.
disableTransitionOnChange as a substitute.