Repository navigation
perf: stop the web-font swap from shifting prerendered text - #17
Merged
Merged
Conversation
Poppins becomes font-display: optional, from the site's own @font-face rules (the @fontsource CSS hard-codes swap), and all four subsets are preloaded. Kay Pho Du keeps swap so the name always ends up in its font; the home page name can't wrap any more, so the swap can't change its line count. CLS on slow 4G: 0.04-0.08 before, at most 0.0002 after, at 320-1366 px in both languages.
✅ Deploy Preview for rainbow-halva-839807 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #16 the pages paint before the web fonts arrive. Lighthouse on the live home page showed CLS 0.043 (mobile), and on a throttled phone it reached 0.04 to 0.08 depending on width. The cause is the Poppins and Kay Pho Du
font-display: swap: text laid out while a font was still pending wrapped differently once it settled. Your name flipped from two lines to one at 360 px, the stack line at 412 px, the role line at 1024 px. With every@font-faceremoved the shift is 0 at all widths, so it is the swap itself, not the fallback faces.Changes
src/fonts.cssreplaces the@fontsourceCSS imports with the site's own rules, for the Latin and Latin Extended subsets only.font-display: optional. The page never re-lays out text for it.swap, so the name always ends up in its own font.index.htmlalso preloads the two Latin Extended files (5.6 KB and 1.4 KB). "Košarica" and the Slovenian pages use them, and a miss would show "š" in the fallback mid-word.Header.css: the home page name can't wrap (.name:not(.md-text),nowrap). On phones it ismin(3rem, 14vw), so it fits at 320 px. Extension titles still wrap.Trade-off
On a slow connection (Lighthouse's slow-4G profile), Poppins misses the
optionalwindow. That visit keeps the size-matched Arial fallback, and the next full page load uses the cached font. On Wi-Fi and fast 4G, Poppins renders on the first visit (checked with CDPgetPlatformFontsForNode). The name always renders in Kay Pho Du.Verified