Prevent layout shift while Spline Sans loads - #1487
Open
skyfallwastaken wants to merge 1 commit into
Open
Conversation
Contributor
Greptile SummaryThis PR changes how Spline Sans is loaded to reduce font-swap layout shift. The main changes are:
Confidence Score: 5/5Safe to merge with minimal risk. The changes are narrowly scoped to font loading and global CSS fallback behavior, and the client and SSR Inertia entrypoints remain aligned. No files require special attention.
What T-Rex did
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant CSS as application.css
participant Tailwind as main.css
participant JS as Inertia/SSR entries
Browser->>CSS: request render-blocking stylesheet
CSS->>CSS: "import @fontsource-variable/spline-sans"
CSS->>Tailwind: import app Tailwind styles
Tailwind-->>Browser: font stack includes Spline Sans Fallback
Browser->>JS: load and hydrate Inertia app
JS-->>Browser: resolve pages and layouts without font imports
Reviews (1): Last reviewed commit: "Prevent layout shift while the app font ..." | Re-trigger Greptile |
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 of the problem
After restoring the signed-in dashboard's eager SSR path, a smaller layout shift remained during hydration. Spline Sans was imported by the Inertia JavaScript entrypoint, so the browser initially laid out the SSR HTML with its substantially wider system fallback. When Spline Sans loaded, the GitHub banner changed from three lines to two and moved the already-rendered dashboard upward by 24px.
Cold Playwright runs measured CLS of 0.0335 from this font swap. Blocking the Spline Sans request eliminated the shift, confirming the cause was font metrics rather than deferred dashboard data or hydration markup.
Describe your changes
On three cache-isolated Playwright runs through the Amp Portal, measured CLS fell from 0.0335 to 0.00098 (about a 97% reduction). The eager dashboard remained present in raw SSR with zero skeletons and no
dashboard_statspartial request.Validated with:
docker compose exec -T web bun run checkdocker compose exec -T web bin/vite build --forcedocker compose exec -T web bin/vite build --ssr --forceScreenshots / Media
N/A — the final rendering is unchanged; this prevents movement while the existing font loads.