Repository navigation
Website: fonts cut to what the site uses, no shift as they arrive, fleet before the engine - #14
Merged
Merged
Conversation
…eet before the engine - Fonts: scripts/fonts.mjs (run by astro.config.mjs before dev, build and check) subsets the Fontsource files to the characters, weights and styles the site uses. Newsreader keeps its optical sizes and weights 400-600: 132 + 147 KB -> 59 + 14 KB; the italic (only the replay's caption) is preloaded on the home page only. Saira Stencil One is cut to the letters of the name, unhinted: 21 KB -> 1.3 KB, inline in the page, so the name draws at the first paint with no request. - No shift when the font arrives: laid out in a fallback first, the hero's text wrapped differently and pushed the buttons and the board (mobile CLS 0.13 on the live site). The page now shows once Newsreader is in, which is normally with the page itself; after 0.6 s (or if fonts are blocked) it shows in the metric-matched fallback and keeps it. - Logo drawn inline in the site's colours (one SVG for both schemes, no requests). - The replay's empty board is drawn at build time, and its shot count has room for two digits, so going from 9 to 10 moves nothing. - Play page: a random fleet is drawn in the page script (uniform, as Layout::random), so placing never waits for the engine; the status line is right from the first paint. The engine downloads once the page is complete and drawn, so the font and script aren't sharing the connection with it; Start waits for it if pressed sooner. - Canonical URL of /play without the trailing slash (it redirected); "Save it for offline play" links to /broadside directly (the .html address redirected). Lighthouse, mobile (simulated slow 4G), local build served with brotli as on Vercel: home LCP 2.6 s -> 1.5 s, play LCP 3.4 s -> 1.2 s, both scores 100; bytes 316 -> 91 KB (home) and 467 -> 227 KB (play). Real throttled Chrome (slow 4G, 4x CPU): CLS 0 on both pages, mobile and desktop, light and dark; play LCP 2.5 s -> 0.75 s.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What changes
site/scripts/fonts.mjs, run byastro.config.mjsbefore dev, build and check). Newsreader keeps its optical sizes and weights 400 to 600: 132 + 147 KB becomes 59 + 14 KB. The italic, used only for the replay's caption, is preloaded on the home page only. Saira Stencil One is cut to the letters of the name and unhinted: 21 KB becomes 1.3 KB, inline in the page.Layout::randomdoes, so placing never waits for the WebAssembly engine. The status line is final from the first paint. The engine downloads once the page has loaded and been drawn; pressing Start before then waits for it./playno longer has the trailing slash (it redirected). "Save it for offline play" links to/broadsidedirectly, so the.htmlredirect is skipped.Measured
Lighthouse mobile (simulated slow 4G), on the local build served with brotli like Vercel. Median of 3 runs:
Real throttled Chrome (slow 4G, 4x CPU slowdown): CLS 0 on both pages, mobile and desktop, light and dark (before: 0.016 on home mobile, 0.003 on desktop). Play LCP went from 2.5 s to 0.75 s.
Checked
npm run check(from a clean state, as CI runs it),npm run build,cargo clippy --all-targets,cargo test: all pass.broadside.html, including pressing Start before the engine has arrived on slow 4G. No console errors.