Skip to content

perf(home): cut the home page's first-visit document and font cost - #54

Merged
maxitect merged 3 commits into
mainfrom
feat/52-home-page-lcp-get-production-lighthouse-mobile-to
Nov 13, 2026
Merged

maxitect merged 3 commits into
mainfrom
feat/52-home-page-lcp-get-production-lighthouse-mobile-to

Conversation

@maxitect

@maxitect maxitect commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Production Lighthouse mobile sat at 85 to 90 with LCP 3.2 to 3.7 s while a local production build scored 93 or more. The gap came from a header Payload adds to every page, not from the page. This PR removes it, plus one unused font preload.

Changes

  • Critical-CH: Sec-CH-Prefers-Color-Scheme (added to every route by withPayload) now applies to /admin only. Chrome answers Critical-CH on a first visit by discarding the document response and requesting it again, so every new visitor to a public page paid the time to first byte twice. On production that first discarded request took 427 ms in Lighthouse ("" row, 71 B, in the network log) against 5 ms locally, which is why only production was slow. The admin still gets the header, so its dark-mode detection is unchanged.
  • The public layout no longer loads Goudy Heavyface. Nothing on the public site uses it (the calendar loads its own copy in src/lib/calendar/fonts.ts), yet it was preloaded on every page.
  • The home page document was already static: ○ / in the build output, x-nextjs-prerender: 1 and cache-status: "Next.js"; hit on production. No change needed.

Acceptance criteria

AC Result Method Evidence
Lighthouse mobile on production for / scores 90+, median of three, LCP under 2.5 s PASS on the deploy preview, production pending merge deploy AC1 below. Preview: 95 / 97 / 97 and 96 / 96 / 97, LCP 1.7 to 2.4 s. Production today: 87 and 90 medians, LCP 3.4 to 3.7 s. Re-run on production after merge
Home hero looks the same at 1280 and 390 px, English and French PASS browser AC2 below
Teaser autoplays with its poster, through HLS first PASS browser AC3 below
No console errors or CSP violations on the home page PASS browser AC4 below

Closes

Closes #52

Notes

  • Functions region (user step, not done). The Netlify docs say changing the functions region "is available on all Pro and Enterprise plans" (https://docs.netlify.com/build/functions/optional-configuration/). This site is on the legacy free plan, so it can't be moved to Frankfurt without upgrading. If the plan changes: Netlify UI, site clarksbowlingclub, Cloud compute, Functions, Region tab, Configure, pick EU (Frankfurt) (fra; the ticket's eu-central-1 is the AWS name), Save, then redeploy. It would not move the home page score: / is served from the CDN cache and runs no function, so this is for the dynamic routes (/api/*, /calendrier, the admin) that read Neon in Frankfurt.
  • After merge: run npx -y lighthouse@12 https://clarksbowlingclub.com --form-factor=mobile --chrome-flags="--headless=new" three times and confirm 90+ and LCP under 2.5 s. Single runs vary by up to 10 points from one machine (production alone gave 79 to 94 today).
  • LCP element on every run is the footer copyright <span>, painted from the server HTML. Lighthouse's simulated LCP counts the fonts and scripts requested before that paint, so fewer early bytes and one fewer document round trip lower it.
  • On preview URLs Netlify injects an iframe of app.netlify.com, which the site's CSP blocks and logs as one console error. It is not present on production and not caused by this PR.
  • Not touched: src/lib/security/headers.ts, the carousel, About page and Payload config (Carousel photos in Payload, with images compressed on upload #43).

Review

Verdict: ALL CLEAR
Rounds: 2

Finding Severity Resolution
The admin-only re-scope silently stops working if a Payload upgrade renames or drops Critical-CH warning fixed in a4c7c54

Also checked: only Payload's admin Root layout reads Sec-CH-Prefers-Color-Scheme (getRequestTheme), and the admin still gets the Critical-CH retry, so its first-load theme is unchanged (same data-theme as production in dark and light). /api/* and /calendrier never read it. #34's CSP, X-Frame-Options, Referrer-Policy and Permissions-Policy are still sent on /, /about, /tour, /api/*, /admin/*, /calendrier and a 404, on the preview and locally. Goudy: no font-goudy class or variable anywhere on the public site. /, /about, /tour, /music and /lyrics at 390 and 1280 px use the same font families and page heights as production, with pixel-identical screenshots outside the home video frame and image compression noise on /about (.git/ticket/52/artefacts/review/). Lighthouse at 00:53 UTC, interleaved: production 76 / 88 / 96 (median 88, LCP 3.43 s), preview 98 / 95 / 98 (median 98, LCP 1.99 s). First visit document requests: production 2 on / and /about, preview 1 (2 on /admin).

Re-verified: AC1 (deploy and local build: Critical-CH only on /admin*, one document request on /, throws when Payload's rule loses it) PASS, AC3 (browser, local build: autoplay, poster, hls/master.m3u8 first, 390 and 1280, EN and FR) PASS, AC4 (browser, local build: no console errors) PASS · check.sh PASS

Evidence

AC1

Lighthouse 12, mobile, headless Chrome, three runs each, 13 November 2026.

production https://clarksbowlingclub.com/ (before)
79  LCP 3.9 s  FCP 2.3 s
94  LCP 2.4 s  FCP 1.4 s
87  LCP 3.7 s  FCP 1.4 s        median 87
90  LCP 3.4 s  FCP 1.4 s
91  LCP 3.2 s  FCP 1.4 s
81  LCP 3.6 s  FCP 1.9 s        median 90

deploy-preview-53 (main plus #43, no fix), same minutes
83  LCP 3.7 s  FCP 1.5 s
89  LCP 3.2 s  FCP 1.5 s
89  LCP 3.2 s  FCP 1.5 s        median 89

deploy-preview-54 (this PR)
95  LCP 2.4 s  FCP 1.0 s
97  LCP 1.7 s  FCP 1.1 s
97  LCP 2.4 s  FCP 1.0 s        median 97
96  LCP 1.7 s  FCP 1.0 s
96  LCP 2.4 s  FCP 1.0 s
97  LCP 2.2 s  FCP 1.0 s        median 96
$ curl -sI https://clarksbowlingclub.com/ | grep -i "ch:"
accept-ch: Sec-CH-Prefers-Color-Scheme
critical-ch: Sec-CH-Prefers-Color-Scheme
$ curl -sI https://deploy-preview-54--clarksbowlingclub.netlify.app/ | grep -i "ch:"
(none)
$ curl -sI https://deploy-preview-54--clarksbowlingclub.netlify.app/admin | grep -i "ch:"
accept-ch: Sec-CH-Prefers-Color-Scheme
critical-ch: Sec-CH-Prefers-Color-Scheme

AC2

Screenshots of production and the preview at 1280 and 390 px with ?isFrench=false and ?isFrench=true (the preview ones carry Netlify's grey preview bar at the bottom): .git/ticket/52/artefacts/{prod,preview}-{1280,390}-fr{false,true}.png. The 390 px French pair was compared by eye: header, toggle, video controls, footer text and position are identical.

AC3

preview 390  fr=false {"paused":false,"currentTime":4.95,"poster":"/videos/teaser-poster.jpg","lang":"en"} first media: hls/master.m3u8
preview 1280 fr=false {"paused":false,"currentTime":5.37,"poster":"/videos/teaser-poster.jpg","lang":"en"} first media: hls/master.m3u8
preview 390  fr=true  {"paused":false,"currentTime":4.47,"poster":"/videos/teaser-poster.jpg","lang":"fr"} first media: hls/master.m3u8
preview 1280 fr=true  {"paused":false,"currentTime":4.95,"poster":"/videos/teaser-poster.jpg","lang":"fr"} first media: hls/master.m3u8

AC4

prod    (all four runs) console: []
preview (all four runs) console: ["error: Framing 'https://app.netlify.com/' violates ... frame-src ..."]  (Netlify's preview drawer, see Notes)

@netlify

netlify Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for clarksbowlingclub ready!

Name Link
🔨 Latest commit a4c7c54
🔍 Latest deploy log https://app.netlify.com/projects/clarksbowlingclub/deploys/6af6604ddb20d027f3487e71
😎 Deploy Preview https://deploy-preview-54--clarksbowlingclub.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@maxitect
maxitect marked this pull request as ready for review November 13, 2026 00:56
@maxitect
maxitect merged commit c2dc9bf into main Nov 13, 2026
5 checks passed
@maxitect
maxitect deleted the feat/52-home-page-lcp-get-production-lighthouse-mobile-to branch November 13, 2026 00:58
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.

Home page LCP: get production Lighthouse mobile to 90+

1 participant