Skip to content

Epic: public site performance, iteration 2 — route splitting, immutable assets, and the post-Sentry loose ends #802

Open

Description

@thinkclay

Follow-on to the first public-site pass (#778 Track A, #791's audit, #793's Sentry removal). Planned 2026-09-17 from the nightly Lighthouse run on main at c67f930d2 — the first run where every page passes the ratcheted budgets bar one CLS warning. This epic is the next ratchet. (Step 1 shipped 2026-09-17; the harness changed with it — see the note under step 1 before reading this table.)

Where we are

Nightly Lighthouse CI run 35206759488, mobile preset, CI runner, brotli on the wire, median of 3:

page perf FCP LCP SI TBT TTI CLS wire
/ 0.67 2119 2119 4057 2143 17866 0.020 2.89 MB
/contact 0.67 1974 1974 4282 2002 17499 0.002 2.88 MB
/jobs 0.62 1761 1807 7851 2427 18425 0.001 2.89 MB
/privacy 0.67 1969 1969 4408 2026 17520 0.000 2.88 MB
/support 0.63 1966 1966 4554 1990 17480 0.114 2.88 MB
/terms 0.68 1697 1697 4618 2006 17568 0.002 2.88 MB

Two weeks ago /jobs was LCP 94 s and CLS 0.98; / scored 0.52. The paint metrics are now fine. What is left is uniform across pages and is not download: 2.9 MB on the wire, but 2.0–2.4 s of main-thread blocking and ~17.5 s to interactive, because every page parses and executes the whole 13.6 MB entry bundle. That single fact orders everything below.

The plan, in order

1. The lever — route splitting (#797) — done, #803 merged 2026-09-17

Enabled asyncRoutes: { web: 'production' }: 13.6 MB → 8.5 MB of JS per public page (2.88 → 1.55 MB brotli), mapbox-gl and the assessment corpus in their own route chunks. Same machine, same harness: TBT −25–40 %, TTI −27 % on every page, paint metrics unchanged.

What it took, so nobody re-derives it: the async came from React's bootstrapScripts, which @expo/router-server's streaming renderer hands the chunk list to; upstream fixed it in 57.0.10, and patches/@[email protected] back-ports that (drop with the SDK 57 bump, #483). The server-side rewrite this epic proposed would have fixed CI only — production is the EAS worker and never runs apps/scaffald/server/index.js.

  • Boots on every public route — 12/12 page×device pairs; new scripts/audit/boot-pages.mjs runs in the Lighthouse job before it measures, because hydration-pages.mjs reported clean on a build whose JS died before hydration
  • Per-page JS ~8.5 MB with mapbox-gl and luscher-test in route chunks
  • SSR metadata and JSON-LD unchanged; client navigation into a split route works
  • Lighthouse before/after on Route splitting works and the result does not boot: async script tags race the shared chunk #797 and the PR
  • Dangling NOTE replaced
  • Budget ratchet in .lighthouserc.json — after the first nightly on main with devtools throttling (see the harness note below), not from a guess

Harness change to know about: .lighthouserc.json now uses throttlingMethod: devtools. The default simulated mode produced a bimodal LCP — 2.2 s or 13 s on the same commit — because Lantern estimates from an unthrottled trace and folds hydration into LCP whenever Chrome's first paint lands after the deferred chunks (which finish in ~450 ms on localhost). Real throttling is stable to ~100 ms. The table at the top of this epic and every nightly before 2026-09-17 are not comparable with runs after it. First devtools-throttled CI run on the merged code: perf 0.68–0.79, LCP 1.3–3.0 s (/jobs highest), TBT ~0.93 s, TTI ~13 s.

2. Cheap, independent, any session — do these first or alongside — S each

3. After splitting: shrink what __common still carries — M

Only worth measuring once step 1 lands, because the split changes what is shared.

  • Metro tree shaking experiment — EXPO_UNSTABLE_TREE_SHAKING=1 EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH=1 expo export, one run, one attribution, hydration audit. lucide-react-native is sideEffects: false, so its 1.14 MB barrel is the headline candidate; zod and our own barrels come along. Zero code change if it holds.
  • If tree shaking does not hold: the deep-import codemod from Finish the icon consolidation: bump the ui pointer, once ui-docs can resolve lucide-react-native in CI #795 option 1 (246 barrel importers; note the package exports map only exposes . and ./icons, and metro.config.js:19 enables package exports, so the resolver needs an exception)
  • Re-attribute packages/scf-core (2.2 MB, our largest single area) now that Sentry and the icon fork are gone — what marketing pages still pull from it that a (public) group layout should not

4. Keep the measurement honest — S

  • Add a per-page JS-weight line to the nightly (total-byte-weight is already in the LHRs; print it beside the metrics) so a bundle regression shows up without a manual audit
  • Turn Bundle audit: what the 17.4 MB web entry bundle is actually made of #791's source-map attribution walk into scripts/audit/bundle-attribution.mjs so steps 2, 3 and every future "before/after" use the same numbers

Shipped to production — 2026-09-17

scripts/deploy-web-eas.sh prod from a clean worktree at 50b93fcc4 (deployment scf-scaffald--mutwtwajzh, CloudFront invalidated). Verified on scaffald.com: chunks emitted defer in order, entry bundle public, max-age=31536000, immutable, HTML caching unchanged, 12/12 page×device boots, 18/18 hydration clean, JSON-LD intact, /privacy no longer names Sentry, 1.72 MB brotli JS per page. Edge functions were not redeployed — nothing under packages/supabase/functions changed behaviour since 1bdcc0dfd (only #771/#776/#780 tooling), and migration 352 (#784) was already applied.

Decisions for Clay

Each has a recommendation so a session can proceed and be overruled.

  1. Route splitting works and the result does not boot: async script tags race the shared chunk #797 stopgap vs wait. Recommend the server-side rewrite now, upstream issue in parallel. Nothing upstream fixes it, including SDK 57.
  2. No remote error reporting since Sentry left: wire logger.error and ErrorBoundary to PostHog exception capture, or decide on none #800 error reporting. Recommend PostHog exception capture; the alternative is accepting blindness and saying so in logger.ts.
  3. Store metadata and RELEASE-PROCESS still name Sentry; the privacy page's effective date and core.legal_documents disagree #801 legal version. Recommend no legal_documents bump — removing a processor narrows the policy and a bump forces every user through re-acceptance.
  4. Content-hashed assets are cached for one hour, so every repeat visitor re-downloads 17.4 MB #788 needs AWS. Either you run it, or a session gets the credentials from Rotate the AWS credentials carried over from the Unicorn org, then prune 11 dead secrets #486's rotation.

Carried from the last session, not performance

What is solid

  • Every public page passes the ratcheted budgets except one 0.014 CLS overshoot; LCP is 1.7–2.1 s everywhere; a11y is 1.0 on / and /contact; hydration is clean across 15 page×device pairs.
  • Sentry is gone (17.4 → 13.6 MB) and the duplicate icon set is gone on main, pending the attribution proof.
  • The measurement is trustworthy: brotli like production, per-device SSR, three runs, and a Lighthouse job that has completed on every push since ci(lighthouse): measure the bundle the way production serves it #789.
  • Production, preview and dev were verified on the same commit at the end of the last pass; production has not been redeployed since perf: remove Sentry — 17.4 MB → 13.6 MB #793, so scaffald.com still ships Sentry and its privacy text until the next scripts/deploy-web-eas.sh prod.

Ship

Same route as #778: merge to main (auto-deploys dev.scaffald.com), verify on the run's per-deploy *.expo.app URL, scripts/deploy-web-eas.sh prod from a clean worktree at origin/main, then curl -sI the entry bundle and the HTML for #788 and re-run Lighthouse for the before/after on #797.

Related: #778 (v1.18.0 epic, Track A), #791 (audit), #797, #795, #788, #800, #801, #774 (closed baseline).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions