perf: preload Poppins + font-display: swap (metric: CLS) - #4
Open
phyceClaw wants to merge 1 commit into
Open
Conversation
Metric: Cumulative Layout Shift (mobile home 0.330 -> expected ~0)
Lighthouse attributes the homepage layout shift to font loading, not to
the plugin table:
layout-shift score 0.3299
culprit: Web font loaded - /fonts/poppins-400.woff2
culprit: Web font loaded - /fonts/poppins-500.woff2
The @font-face blocks had no font-display, so the browser used the
default `auto` (block, then swap) and there was no preload, so the fonts
were only discovered after app.css parsed. Text painted in the fallback
and then reflowed once Poppins arrived.
Adds font-display: swap to all three faces and preloads the two weights
that render above the fold (400 and 500). Both files are ~7.8 KB, so the
preload cost is negligible against the shift it removes. Weight 700 is
not preloaded - it is not an above-the-fold face and Lighthouse did not
flag it as a shift culprit.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Metric targeted: Cumulative Layout Shift
Homepage mobile CLS is currently 0.330 (Lighthouse, Chrome 151, mobile preset). Lighthouse attributes the shift to font loading — not to the plugin table:
Cause
The three
@font-faceblocks inresources/css/app.cssdeclare nofont-display, so the browser applies the defaultauto(block, then swap). There was also no<link rel=preload>, so the fonts were only discovered onceapp.csshad been parsed. Text paints in the fallback and then reflows when Poppins arrives.Change
font-display: swapon all three faces.app.blade.php.Both font files are ~7.8 KB, so the preload cost is negligible relative to the shift it removes. Weight 700 is deliberately not preloaded — it is not an above-the-fold face and was not flagged as a shift culprit.
Verification
npm run buildpasses andfont-display:swapis present in the emittedapp-*.css.🤖 Generated with Claude Code