Title: fix: preload LCP fonts instead of the wrong hero image · Issue #550 · ycode/ycode · GitHub
Open Graph Title: fix: preload LCP fonts instead of the wrong hero image · Issue #550 · ycode/ycode
X Title: fix: preload LCP fonts instead of the wrong hero image · Issue #550 · ycode/ycode
Description: Summary On the client website both mobile Lighthouse runs (14 Sep 2026) named the H1 “Your AI Co-Host for Streams & Communities” as the LCP element, with LCP between 3.9 s and 11.4 s. The headline is in the SSR HTML — it is not injected ...
Open Graph Description: Summary On the client website both mobile Lighthouse runs (14 Sep 2026) named the H1 “Your AI Co-Host for Streams & Communities” as the LCP element, with LCP between 3.9 s and 11.4 s. The headline ...
X Description: Summary On the client website both mobile Lighthouse runs (14 Sep 2026) named the H1 “Your AI Co-Host for Streams & Communities” as the LCP element, with LCP between 3.9 s and 11.4 s. The headl...
Opengraph URL: https://github.com/ycode/ycode/issues/550
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix: preload LCP fonts instead of the wrong hero image","articleBody":"## Summary\n\nOn the client website both mobile Lighthouse runs (14 Sep 2026) named the H1 **“Your AI Co-Host for Streams & Communities”** as the LCP element, with LCP between **3.9 s and 11.4 s**.\n\nThe headline **is in the SSR HTML** — it is not injected after hydration, and GSAP initial CSS does **not** hide it (`data-gsap-hidden` is used for mobile nav / other layers, not this H1). The delay is from **font loading + competing network/CPU**, not from animation initialisation of that heading.\n\nReports: PageSpeed Insights runs shared by the client (links kept out of the tracker).\n\nRelated platform JS cost: #548, #549.\n\n## What we found\n\n### 1. Wrong LCP candidate (high-priority image steal)\n\n`findLcpCandidate()` in `lib/asset-utils.ts` only considers **images**. On this homepage it picks a 40×40 social-proof avatar (`narianazone.webp`) because:\n\n- it is the first non-header/nav `image` layer\n- the layer’s `width`/`height` attributes are **300** (asset intrinsic), even though CSS renders it at 40px\n- `minWidth` is 200, so 300 passes\n\n`PageRenderer` then emits:\n\n```html\n\u003clink rel=\"preload\" as=\"image\" … fetchPriority=\"high\">\n```\n\nand the `\u003cimg>` gets `loading=\"eager\"` + `fetchPriority=\"high\"`.\n\nThat competes with the **actual** LCP (text) and with the Google Font files. The heuristic never considers a large H1 as LCP.\n\n### 2. LCP webfont is not preloaded\n\nThe H1 uses **Plus Jakarta Sans** 700 at 60px / 48px / 36px (`font-display: swap`). We already:\n\n- inline `@font-face` CSS (skip `fonts.googleapis.com`)\n- `preconnect` `fonts.gstatic.com` (response `Link` header + `\u003clink>`)\n- preload **uploaded custom** font files\n\nWe do **not** preload the latin woff2 for Google families. Custom-font preload was added in `198daea9`; Google fonts were left as CSS-discovered. Until Plus Jakarta Sans arrives, LCP for that H1 is delayed (swap) or painted with a fallback then updated.\n\nThe site also inlines **66 `@font-face` rules** (Inter + Plus Jakarta Sans, including italic + many unicode-range subsets). Inter italic is requested because `buildGoogleFontUrl()` adds the full italic axis whenever the installed font’s variants include italic — even if the page barely uses italic.\n\n### 3. Runtime / animation\n\n- `AnimationInitializer` (GSAP + ScrollTrigger + SplitText, ~136 KB / ≈51 KiB gzip) **does** load because the page has interactions. That is correct gating; it is not what hides the H1.\n- Hydrating `LayerRendererPublic` plus the duplicate chunks in #548 is the main **TBT** (650–730 ms) contributor alongside third-party tags (GTM; customer is reviewing tracking separately).\n- Background video (`cloth-optimised-1080p30.mp4`) is in the hero; the customer already cut homepage download ~7.3 → 4.4 MiB. Remaining video still contends for bandwidth on mobile.\n\n## Proposed fix\n\n- Extend LCP selection beyond “first large image”:\n - skip images whose **rendered** size is tiny (avatar/logo), not just SVG / header/nav\n - if the largest above-the-fold element is text (hero H1), do **not** `fetchpriority=high` a competing image\n- Preload the latin (and used-weight) woff2 for Google fonts that appear on likely LCP text, same as custom fonts.\n- Subset Google Font CSS to weights/styles actually used on the page (or at least skip italic when unused).\n- Optional: `font-display: optional` for non-LCP faces so the LCP face wins the connection.\n\n## Customer-facing settings (today)\n\nThere is **no** Ycode setting that preloads Google fonts or marks a layer as LCP. Until this ships, they can still:\n\n- Avoid on-load / scroll-into-view hide or SplitText on the hero headline (this page already does not hide it)\n- Keep third-party tags out of the hero path (they are reviewing this)\n- Keep the background video muted / `playsinline` and prefer a poster on mobile if they still see LCP contention\n- Not install unused italic/weight variants if we later subset by installed variants — today installing a family with italic still fetches the full italic axis\n\n## Test plan\n\n- [ ] Client website (or equivalent hero-text homepage): Lighthouse LCP element stays the H1, and no 40px avatar is preloaded with `fetchpriority=high`\n- [ ] HTML contains `\u003clink rel=\"preload\" as=\"font\">` for the H1’s latin woff2\n- [ ] A page whose LCP **is** a large hero image still gets image preload + eager\n- [ ] Pages without Google fonts do not emit extra preloads\n- [ ] Mobile LCP on a text-hero page moves toward the CrUX 2.4 s band rather than 4–11 s lab\n","author":{"url":"https://github.com/ysamcode","@type":"Person","name":"ysamcode"},"datePublished":"2026-09-15T05:44:37Z","url":"https://github.com/ycode/ycode/issues/550"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:193cd086-9d50-16f0-f48e-2e43ee08561c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 987E:56627:A5472:D6214:6AFE3326 |
| html-safe-nonce | b587c66567cd92435f5610f08a349c4a4dd2c200980f77997f2212adc7f658f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODdFOjU2NjI3OkE1NDcyOkQ2MjE0OjZBRkUzMzI2IiwidmlzaXRvcl9pZCI6IjI0MjQ3NDcxMjc2MDQxMzA1OTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f7fd49f20a2b5a19124aaddaea1612aaac93226134fd221e3da461d4326d76ab |
| hovercard-subject-tag | issue:5458044061 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ycode/ycode/550/issue_layout |
| twitter:image | https://opengraph.githubassets.com/568f4edf9a973acc0b103403819468815f02b3bad70efdb0281d47ed29533827/ycode/ycode/issues/550 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/568f4edf9a973acc0b103403819468815f02b3bad70efdb0281d47ed29533827/ycode/ycode/issues/550 |
| og:image:alt | Summary On the client website both mobile Lighthouse runs (14 Sep 2026) named the H1 “Your AI Co-Host for Streams & Communities” as the LCP element, with LCP between 3.9 s and 11.4 s. The headline ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ysamcode |
| hostname | github.com |
| expected-hostname | github.com |
| None | d70e31220a67f6376c108d2416fa8e7df854c1065b1672ab7a88ab6dc3a809e2 |
| turbo-cache-control | no-preview |
| go-import | github.com/ycode/ycode git https://github.com/ycode/ycode.git |
| octolytics-dimension-user_id | 65892203 |
| octolytics-dimension-user_login | ycode |
| octolytics-dimension-repository_id | 1165452593 |
| octolytics-dimension-repository_nwo | ycode/ycode |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1165452593 |
| octolytics-dimension-repository_network_root_nwo | ycode/ycode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ccb88d9c92abe69245b429398c8a57ae87070c7c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width