Stop shipping the shell code no route can reach

Performancekamo-internal
Shipped
August 26, 2026 at 12:52 AM UTC
Author
kamo
Commit
0a36119

Batch 1 of the client-side performance audit. Every change is behaviour-preserving; nothing a member can see or do is different afterwards. I18nProviders imported four locale barrels with `import * as` and indexed them by a runtime key. A namespace read by a computed key is untree-shakeable by construction, so all 236 locale objects shipped when the app maps 74. Measured with esbuild against the exact import forms: 1,283 KB -> 421 KB minified, 216 KB -> 77 KB gzip. That chunk is on 143 of 143 page routes, so it was parse-and-execute work before hydration on every page load. All 88 locale mappings (22 locales x 4 maps) verified to resolve to the identical export as before. createPhoneSdk statically imported all three adapters, so sip.js AND ringcentral-web-phone reached every member on every route — including orgs with no phone provider and Teams members, who need neither. The adapter modules are now reached through `await import()`, which is why the factory is async; its only caller was already an async callback. TeamsAcsPhoneSdk already deferred the Azure SDK this way, so this extends an established pattern rather than inventing one. useFormatters built two Intl.DateTimeFormat objects on every `custom()` call and a fresh Intl.NumberFormat on every number/percent/currency call. On a grid with two date columns over ~25 rows that is 50 constructions per sort, filter or scroll refresh. Now served from a process-wide cache: 2,028 comparisons across 12 locales, 5 zones and 8 option shapes produce byte-identical output, and 20,000 formats went 12,720ms -> 308ms. MeetingDialog (@mui/x-date-pickers' DateTimePicker) and the sticky-note Lexical editor were both static imports in the always-mounted shell for surfaces that start closed. Both are deferred now. The editor is deferred at FloatingNote rather than at FloatingNoteLayer on purpose — lazifying the layer would collapse AnimatePresence's child tracking and silently drop the sticky's close animation — and FloatingNoteLayer warms the chunk on idle so the first open stays instant rather than becoming a fetch. NavLayout, SettingsAppPins and FloatingNotes each fetched the whole member ui-preferences document for themselves, though a coalescing reader for exactly that endpoint already existed in the same codebase. All three now share it, and their writes go through the shared writer so the cached map cannot go stale. Adds a matching deleteMemberUiPreference for NavLayout's reset path, which would otherwise have left a deleted key sitting in the cache. blake3's browser build is now imported lazily. It was pulled in by anything importing MAX_UPLOAD_BYTES or formatFileSize from the same module, so its WASM was fetched and compiled during first paint for a function that only runs after a file picker. next.config: productionBrowserSourceMaps defaults off (opt back in for a debugging build with KAMO_BROWSER_SOURCEMAPS=true). It was emitting 349 map files, 103.7 MB, all carrying sourcesContent — the complete original TypeScript of this app, served from /_next/static to anyone who can reach the host. Also drops the dead `env` block: KAMO_OAUTH2_CLIENT_PASSWORD has zero references in source and appears in zero client chunks, so nothing was leaking, but the block is a standing invitation to inline the secret the moment a client component reads it. Deliberately NOT done: setting `compress: false` to let Traefik's brotli take over. Traefik's compress middleware allow-lists content types and the list omits application/javascript and application/json, which is exactly what Next serves JS and API bodies as — so disabling Next's gzip would ship every chunk and every API response uncompressed. That needs the allow-list widened in KlusterServices first, as its own platform-wide change. Verified: tsc --noEmit clean; the 7 guard scripts unrelated to in-flight work pass; vitest 3,089 tests pass (the suite is timeout-flaky under concurrent load — the failing set differed per run and all re-ran green in isolation).

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing