Skip to content

Website: fonts cut to what the site uses, no shift as they arrive, fleet before the engine - #14

Merged
AdminGodZ merged 1 commit into
mainfrom
t3/improve-website-performance
Nov 23, 2026
Merged

AdminGodZ merged 1 commit into
mainfrom
t3/improve-website-performance

Conversation

@AdminGodZ

Copy link
Copy Markdown
Owner

What changes

  • Fonts subset at build time (site/scripts/fonts.mjs, run by astro.config.mjs before 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.
  • No shift when the font arrives. The hero text was first laid out in the fallback font, wrapped differently, and pushed the buttons and board down (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 inline in the site's colour variables: one SVG for both colour schemes, and no image requests.
  • Replay board drawn at build time. Its shot count has room for two digits, so going from 9 to 10 shots moves nothing.
  • Play page: the fleet comes before the engine. The page script draws the random fleet the same way Layout::random does, 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.
  • Canonical URL of /play no longer has the trailing slash (it redirected). "Save it for offline play" links to /broadside directly, so the .html redirect is skipped.

Measured

Lighthouse mobile (simulated slow 4G), on the local build served with brotli like Vercel. Median of 3 runs:

Before After
Home score / LCP / bytes 97 / 2.6 s / 316 KB 100 / 1.5 s / 91 KB
Play score / LCP / bytes 92 / 3.4 s / 467 KB 100 / 1.2 s / 227 KB

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.
  • End-to-end games in a real browser on the build, the dev server and the offline broadside.html, including pressing Start before the engine has arrived on slow 4G. No console errors.
  • Screenshots match the old build, apart from the shot counter now ending under the board's edge.

…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.
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
broadside Ready Ready Preview Nov 23, 2026 8:34am UTC

@AdminGodZ
AdminGodZ merged commit bd5ddb8 into main Nov 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant