Skip to content

perf(landing): keep codec off landing via build-time precompute (reworked P1)#300

Merged
ignromanov merged 1 commit into
developfrom
perf/landing-codec-rework
Jun 5, 2026
Merged

perf(landing): keep codec off landing via build-time precompute (reworked P1)#300
ignromanov merged 1 commit into
developfrom
perf/landing-codec-rework

Conversation

@ignromanov
Copy link
Copy Markdown
Owner

What (reworked P1 — replaces the held #296 P1)

Keep the brotli-wasm codec off the landing without the LCP regression that #296's RSC-lift caused.

  • Precompute demo createHash at build time: a prebuild step runs encodeInvoice over RAW_DEMO_INVOICES in Node and emits demo-invoices.generated.ts (static strings, committed). Salt is frozen at build (fine for demos).
  • Client stays codec-free: DemoSection imports only static raw data + precomputed hashes — no @/features/invoice-codec, no getDemoInvoices(). The RSC lift in page.tsx / LandingContent / BelowFoldSections is reverted (back to non-async, no prop threading). DemoSection loads lazily client-side below the fold, as before perf(landing): stop eager 2.7MB video + 581KB codec on mobile landing #296 — so demo content is NOT in the critical render path.

Why (official PSI, mobile, 3× median)

Score LCP SI wasm
develop 72 4.1s 3.4s 1
#296 (RSC lift — held) 76 5.4s 5.1s 0
this rework 85 4.2s 3.5s 0

Reverting the RSC lift brings LCP 5.4 → 4.2 (back to develop baseline) while keeping wasm off the landing (codec goal achieved). This isolates and confirms #296's RSC lift as the LCP regression cause.

media=1 here is the autoplay video (this branch is off develop, without P0). P0 (#299) removes it; the two are independent and compose on develop.

Verification

Pending Iris quality-gate (pipeline + prebuild mechanism + tests).

🤖 Generated with Claude Code

…m client

DemoSection no longer loads brotli-wasm or @/features/invoice-codec at runtime.
createHash strings are generated once during `pnpm build` (prebuild npm hook) via
scripts/generate-demo-hashes.ts + a Node zlib brotli stub that replaces brotli-wasm
for the build-time script. DemoSection imports static data + the generated
demo-invoices.generated.ts module — synchronous, no useEffect async loading.

This reverts the #296 RSC lift (which regressed LCP +1.4s / SI +1.8s) while
still keeping brotli-wasm off the landing client bundle.

Files:
- scripts/generate-demo-hashes.ts — prebuild script that writes createHash strings
- scripts/brotli-node-stub.ts — Node zlib brotli shim for the prebuild tsconfig
- scripts/tsconfig.prebuild.json — tsconfig alias: brotli-wasm → brotli-node-stub
- src/widgets/landing/constants/demo-invoices.ts — exports RAW_DEMO_INVOICES + buildDemoInvoices()
- src/widgets/landing/constants/demo-invoices.generated.ts — placeholder (overwritten at build)
- src/widgets/landing/demo-section/DemoSection.tsx — imports static data, no codec
- src/widgets/landing/demo-section/__tests__/DemoSection.test.tsx — updated for static shape
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
voidpay Ready Ready Preview, Comment Jun 5, 2026 5:36pm

@ignromanov ignromanov merged commit 3c9c4b2 into develop Jun 5, 2026
7 checks passed
@ignromanov ignromanov deleted the perf/landing-codec-rework branch June 5, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant