Skip to content

perf: pass the Core Web Vitals budgets so the Lighthouse lane can graduate to requiredΒ #176

Open
1 of 1 issue completed

Description

@devantler

πŸ€– Generated by the Daily AI Assistant

Part of #100.

Problem

The Lighthouse CI lane (shipped via #148) is now stable β€” 37 consecutive green runs since 2026-06-28 β€” but its warn-only budget assertions fail, so it cannot graduate to a required check yet. Measured on 2026-07-10 (run 29115267510, mobile emulation, 3 runs/URL, median):

  • /: performance 0.66–0.77 (budget β‰₯0.85), FCP 2.1–4.2 s (budget ≀1.8 s), LCP over 2.5 s
  • /login: LCP 2573 ms (budget ≀2500 ms) β€” borderline; other assertions pass

Root causes (ranked, from a code audit of main @ a532251)

  1. Gallery eagerly downloads ~9.1 MB of JPEGs on first paint β€” src/lib/components/Gallery.svelte renders every slide (19 unique files + clones) with loading="eager" fetchpriority="low", saturating the emulated slow-4G link and starving the LCP element. Dominant lever; lazy-loading non-adjacent slides should win multiple seconds of LCP.
  2. Unoptimized JPEGs β€” largest gallery files 855/844/653/628/615 KB, no WebP/AVIF, no srcset; displayed at ~60 vh.
  3. Render-blocking cross-origin CSS β€” src/app.html loads 3 Google-font families (~10 variants) plus the entire Font Awesome 6.7.2 all.min.css from cdnjs (not even preconnected) for ~21 glyphs. Self-hosting fonts + a tree-shaken icon subset targets the 2.1–4.2 s FCP directly (~0.5–1.5 s).
  4. Hero/LCP background not preloaded β€” /gl-brydegaard.jpg (146 KB) is a late-discovered CSS ::before background on both / (Hero.svelte) and /login; no <link rel=preload> exists anywhere.

The JS bundle is NOT implicated (adapter-node precompress: true, bundle-budget gate green).

Proposed direction

Land levers 1β†’4 as small, independently-verifiable PRs (before/after Lighthouse numbers from the CI lane in each PR body). Once both pages pass their assertions consistently (~10 runs), flip lighthouserc.json from warn to error and add the Lighthouse job to the required aggregate β€” closing #100.

Rough size

M overall; each lever is S.

Activity

  1. coderabbitai commented on Jul 11, 2026

    @coderabbitai
    πŸ”— Related PRs

    devantler-tech/monorepo#1989 - docs: require maintainer approval before creating upstream issues/PRs [closed]
    #148 - ci: serve the Lighthouse lane via vite preview to fix its cold-start hang [merged]
    devantler-tech/monorepo#1991 - docs: prioritise substantive issues over easy wins [closed]
    #152 - fix: pin @sveltejs/adapter-node to 5.5.4 β€” 5.5.5 output never boots (prod CrashLoopBackOff) [merged]
    #169 - ci: add required boot-smoke lane for the adapter-node entrypoint [merged]


    πŸ“ Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    πŸ§ͺ Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    πŸ’¬ Have feedback or questions? Drop into our discord!

  2. devantler commented on Jul 11, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Daily AI Assistant

    Measurement caveat from the first two lever PRs (#177 gallery deferral, #178 hero preload): single-run CI Lighthouse comparisons are noise-dominated on GitHub-hosted runners. Three same-day samples for / (median-of-3 each): main 07-10 β†’ perf 0.77 / FCP 2083 ms / LCP 5452 ms; #177 β†’ 0.71 / 3237 / 6356; #178 β†’ 0.67 / 3979 / 7157. /login even fully passed on #177's run (which doesn't touch it) and warned on both FCP+LCP on #178's β€” the spread is runner lottery, not the diffs.

    Consequences for this issue:

    1. Both shipped levers are verified behaviorally (e2e: ≀5 eager slides / preload link present; the eager image payload drops from 19 unique JPEGs (~9.1 MB) to ≀5) β€” but per-PR CWV deltas can't be honestly claimed from one CI sample.
    2. Graduating the lane (warn→error) needs headroom, not just passing medians — with this variance, budgets that pass marginally will flake as errors. The heavy levers (image optimization L2, self-hosted fonts + icon subset L3) must land first, and if margins stay thin, raise numberOfRuns and/or relax budgets to hosted-runner reality before flipping.
    3. Before/after evidence for the remaining levers should use multiple lane runs (re-run the job 2–3Γ—) rather than a single sample.
  3. self-assigned this
    on Jul 18, 2026
  4. devantler commented on Jul 18, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Daily AI Engineer

    Root cause of the remaining gap: the lane measures a transport guests never get

    Re-measured main after #199/#192. First, the status changed since the 07-12 note β€” /login now passes every assertion; only / still misses, on FCP and LCP:

    page FCP (≀1800) LCP (≀2500) perf (β‰₯0.85)
    /login pass pass pass
    / 2499 ms 3365 ms 0.84

    (CI run 29572646607; reproduced locally at FCP 2616 / LCP 3985.)

    What the LCP actually is

    The LCP element on / is not an image β€” it is the <h1> text, and its phase breakdown is decisive:

    phase timing % of LCP
    TTFB 452 ms 11%
    Load Delay 0 ms 0%
    Load Time 0 ms 0%
    Render Delay 3533 ms 89%

    Load Time: 0 confirms no image is on the LCP path at all, so levers 2/4 (responsive images, hero preload) could never have moved it. This is what the 07-12 comment suspected; it is now measured.

    Why render delay is so large

    The render delay is dominated by the document itself, and the document is being sent uncompressed:

    • adapter-node’s precompress: true compresses build-time static assets only β€” _app/immutable/** is correctly served Content-Encoding: br. A server-rendered document is produced per request, and adapter-node ships no runtime compression, so it goes out raw.
    • Measured against the built server: / = 104,952 bytes with no Content-Encoding, even when the client sends Accept-Encoding: br, gzip. Brotli would be ~12 kB β€” an ~8.7x difference, on exactly the resource that gates first paint.
    • /login is ~7 kB raw, small enough for the difference to be immaterial. That is precisely why /login passes and / does not β€” it was never a difference in how well the two pages are built.

    The part that changes the plan

    Production does not have this problem. The site is fronted by Cloudflare:

    $ curl -sD- -o/dev/null -H "Accept-Encoding: br, gzip" https://wedding.platform.devantler.tech/login
    HTTP/2 200
    server: cloudflare
    content-encoding: br
    

    So real guests already receive the compressed document. The uncompressed 105 kB exists only in the Lighthouse lane, which scans the bare adapter-node server with nothing in front of it.

    This means the remaining budget gap on / is substantially a measurement artifact, not a user-facing regression β€” and it also means it cannot be closed by optimising the app further. Note this was missed in the original root-cause audit, which checked the JS bundle (correctly finding it innocent, precompress: true + bundle budget green) but never checked the document response.

    To be explicit about what this does and does not say: levers 1–4 were real improvements and are not invalidated β€” they are why the performance score recovered from 0.66–0.77 to 0.84 and why /login graduated. What changes is the interpretation of the remaining gap.

    Proposed direction

    Make the lane faithful rather than optimise against a phantom: serve both pages through a small compressing proxy in the lane, so it measures the transport production actually delivers. The app and its production entrypoint stay untouched, so the boot-smoke guarantee (#153) is unaffected.

    Draft PR: #202. Before/after numbers are posted there.

    Deliberately not proposing in-app compression: prod already compresses at the edge, so adding it to the SvelteKit server would change the production response path for zero user-visible gain β€” a bad trade on the live wedding site.

  5. devantler commented on Jul 18, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Daily AI Engineer

    #202 merged (ced1325a) β€” the lane now measures the app through a compressing edge, matching how guests actually receive it.

    Effect on the reported numbers (CI, 3 runs/page):

    metric before after budget
    / FCP 2499 ms 1993 ms ≀1800
    / LCP 3365 ms 2783 ms ≀2500
    / performance 0.84 (warned) no longer warned β‰₯0.85
    /login passes passes β€”

    Keeping this issue open. The budgets still do not pass: / is ~193 ms over on FCP and ~283 ms over on LCP. What changed is that the residual is now honest β€” previously a large part of the reported miss was the lane charging the app for ~93 kB of transfer that Cloudflare removes in production.

    Next lever

    The LCP element is the <h1>, and 89% of its time is render delay with Load Time: 0. So the remaining cost is in the critical path to first render, not in assets β€” which also means the earlier image-oriented levers had no remaining headroom to give. Worth profiling next:

    • what the browser is blocked on between the document arriving and the <h1> painting (the three render-blocking stylesheets are small β€” 6.2 kB brotli combined β€” so this may be font loading or style recalculation rather than transfer);
    • whether the program page needs to server-render all 25 gallery slides with full srcsets up front, given only ~5 are within the eager window. The document is ~12 kB brotli / ~105 kB raw largely because of that markup, and DOM construction under 4Γ— CPU throttling is on the critical path.

    The graduation flip in #100 (warn→error + required aggregate) should stay gated until the assertions actually pass.

  6. devantler commented on Jul 23, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Agentic Engineer

    2026-07-23 re-measurement: the budgets still miss on current main

    Reproduced from clean main at dec84fcf with npm ci, DEV_SKIP_AUTH=true npm run build, and the repository's three-run npm run lhci lane:

    page result budget
    /login LCP 2559 ms (2563 / 2559 / 2559) ≀2500 ms
    / FCP 1808 ms (2017 / 2008 / 1808) ≀1800 ms
    / LCP 3159 ms (3386 / 3385 / 3159) ≀2500 ms

    This corrects #204's premise that the Chrome-process flake was the only remaining blocker. The retry makes collection reliable, but the assertions themselves do not yet have positive headroom and must remain warn-only.

    What the current report rules out

    • The / LCP is still the static <h1>; 86–87% is render delay and load time is zero.
    • The compressed document is only ~14.2 kB.
    • Lighthouse scores the 603-element DOM at 1.0, reports zero render-blocking-resource savings, and measures only ~0.3 s of main-thread work.

    That makes further gallery/SSR-markup reduction unlikely to close the measured 659–886 ms LCP gap by itself.

    I also tested one isolated hypothesis: removing the 55 kB hero-background preload so it could not contend with the already-preloaded heading font. It did not improve the result (/ FCP 2008–2013 ms, LCP 3310–3386 ms; /login unchanged at 2561 ms), so the experiment was fully reverted.

    Narrowed next step

    Profile the heading's font-paint timing under the lane's simulated mobile conditions, specifically whether the late Cormorant Garamond swap is what updates the text LCP after FCP. Any proposed change should first reproduce that timing directly, then compare multiple three-run samples; budget relaxation or promotion without positive headroom would turn ordinary runner variance into a required-check flake.

  7. moved this to πŸ“₯ Backlog in 🌊 Project Boardon Jul 25, 2026
  8. added a commit that references this issue on Sep 27, 2026
  9. devantler commented on Sep 27, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Agentic Engineer

    2026-09-27 measurement: fonts are the largest single lever on /, but not enough on their own

    I took the narrowed next step above and profiled / on current main (0d42fc7d), using the lane's own npm run lhci wrapper (three runs, simulated mobile).

    Baseline: FCP 1807 / 2008 / 2015 ms, LCP 3084 / 3308 / 3310 ms, performance 0.91–0.93. The performance score now clears its 0.85 budget. FCP and LCP still miss theirs.

    Why the LCP is late. The LCP element is still the hero <h1>. The late web-font swap turned out to matter only through timing. In the unthrottled trace, the first paint and the LCP happen at the same moment (122 ms), right after the last font arrives. Lighthouse's simulated throttling then charges the page for every non-low-priority request that started before that moment. At the default settings that is:

    Before the LCP Requests Bytes
    Fonts 5 117.9 kB
    Scripts 14 53.1 kB
    Hero background image 1 55.7 kB
    Document + CSS 5 22.4 kB

    The five fonts are Cormorant 300 (the heading), Cormorant 400 and 400-italic, and Inter 400 and 500. Together they are almost half the bytes on the critical path.

    Measured ceiling. As a measurement only (not a proposal), I removed the four fonts the heading does not use and re-ran the lane. That cut FCP to 1505 / 1505 / 1655 ms and LCP to 2636 / 2785 / 2786 ms, which is 450–670 ms better but still over 2500 ms. So fonts are the biggest single lever, but no font change alone gets / under budget. What remains is the hero image and the hydration scripts, about 109 kB between them.

    Candidate slices, in order of expected payoff per risk:

    1. Subset the self-hosted fonts to the glyphs the site uses. The text is Danish, and each latin file is about 23 kB. This keeps the design exactly as it is. Estimate the saving by subsetting one face first, before building a pipeline.
    2. Make the hero background smaller or later. At 55.7 kB it is the largest single file ahead of the LCP. Removing only its preload changed nothing (see above), so this has to reduce its bytes, not its priority.
    3. Reduce the hydration JavaScript ahead of first paint (14 chunks). Only worth it after 1 and 2 have been measured.

    The budgets stay warn-only until the three-run median has real headroom, as agreed above. No code changed in this pass.

  10. devantler commented on Sep 28, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Agentic Engineer

    2026-09-28 measurement: subsetting the fonts saves about a fifth of their bytes

    I measured slice 1 before building anything. I subset the five faces that load ahead of the LCP on /, using HarfBuzz via subset-font 2.9.0 in a scratch directory, not in the repository. I kept the full Latin-1 range plus common typographic punctuation (– β€” β€˜ ’ β€œ ” … β€’ € β„’). Guest names and other dynamic text still render in the design fonts; they do not fall back to a system face.

    Face Shipped Subset
    Cormorant 300 21,908 B 17,684 B
    Cormorant 400 22,876 B 18,496 B
    Cormorant 400 italic 23,660 B 19,424 B
    Inter 400 23,664 B 17,688 B
    Inter 500 24,272 B 18,140 B
    Total 116,380 B 91,432 B (βˆ’21%, about 25 kB)

    What this means for the budget. Dropping four of these fonts outright removed about 94 kB and gained 450–670 ms, and / still missed its LCP budget. Subsetting removes about a quarter of those bytes. Scaled by bytes, that is roughly 120–180 ms, far short of the ~580–810 ms the LCP still needs (baseline 3084–3310 ms against a 2500 ms budget). A tighter subset limited to the glyphs the site's own copy uses would save more. It would also put dynamic text such as guest names at risk, so I am not proposing it.

    Decision. Slice 1 alone is not worth a build step and self-hosted font copies. The next measurement is slice 3: the 14 hydration chunks (53 kB) ahead of first paint. Slice 2 is not promising either. The hero is already served as AVIF at 55 kB, so shrinking it further means a visibly lower-quality image. The subset step stays on the table as part of a combined change once slice 3 is measured. The budgets stay warn-only. No code changed in this pass.

  11. devantler commented on Sep 28, 2026

    @devantler
    ContributorAuthor

    πŸ€– Generated by the Agentic Engineer

    2026-09-28 measurement: the page's JavaScript is worth about as much as the fonts, and none of it can be removed

    This is slice 3 from the previous comment. I measured / on current main (6c5e274) with the lane's own npm run lhci wrapper (three runs, simulated mobile). Each variant was built locally and then reverted; no code changed.

    Variant on / FCP (ms) LCP (ms) Performance
    main as shipped 1808 / 1808 / 2015 3085 / 3086 / 3309 0.91–0.93
    No JavaScript at all (csr = false, measurement only) 1505 / 1506 / 1505 2478 / 2479 / 2403 0.97
    Keep the JavaScript but drop its modulepreload links (resolve(event, { preload })) 1581–1582 4807–4808 0.82

    The LCP element is the same hero <h1> in all three.

    What this shows.

    • The 15 script requests that start before the LCP cost about 600–830 ms of simulated LCP, about as much as dropping the four non-heading fonts did (450–670 ms). With no JavaScript, / is just under its 2500 ms budget.
    • The page cannot ship without it. The gallery, RSVP, room booking, the nav and the back-to-login bar are interactive, so csr = false is only a ceiling.
    • Removing the preloads makes things much worse. The scripts are then found one import at a time, and the simulated slow network charges each step as a separate round trip.
    • The bytes are mostly the framework. Brotli sizes are: Svelte runtime 15.9 kB, SvelteKit client 12.0 kB, and 15.0 kB for this page's own components. No single dependency stands out to cut.

    Decision. No single lever gets / under 2500 ms without removing features or visibly degrading the design:

    • font subsetting: about βˆ’150 ms
    • dropping four fonts: βˆ’450 to βˆ’670 ms, and it changes the typography
    • a smaller hero image: lower quality
    • a lazier JavaScript load: worse, as measured above

    The honest remaining options are:

    1. A combined change: subset the fonts, and load only the heading face ahead of the LCP, so the body faces arrive after first paint. This needs one more measurement to see whether the two savings add up. It is the next slice.
    2. Graduate the lane without the / LCP assertion. Performance score, FCP (once the fonts change lands), CLS and TBT would become required, while / LCP stays warn-only with this evidence recorded. That changes the budget perf: full Lighthouse CI Core Web Vitals budget (deferred from #95)Β #100 set, so it only happens if option 1 falls short.

    The budgets stay warn-only for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Performance.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions