perf(web): preload the configured primary font #120

Merged
eleith merged 2 commits from perf/preload-primary-font into main 2026-11-02 23:25:04 +00:00

Summary

Let the browser discover the primary font from server-rendered HTML instead of waiting for stylesheet discovery.

  • Preload only the regular (400) face of the configured bundled font.
  • Prefer the configured custom font file when present; emit no hint for an unknown family without a custom file.
  • Use as="font", type="font/woff2", and anonymous CORS so CSS can reuse the preload.
  • Leave other weights, fallback fonts, font styling, and font-display: swap unchanged.
  • Include a patch changeset for @when/web.

This is the fonts-only follow-up to #119. CSS, avatar, and timezone changes remain separate. No PageSpeed score improvement is claimed before deployment and measurement.

Validation

  • 35 targeted unit tests passed (font selection, appearance, and the updated admin-health fixture).
  • Chromium E2E passed with JavaScript disabled: exactly one font preload is present in the initial HTML; the regular face is requested once; no unrelated font family is fetched.
  • Svelte check: 0 errors and 0 warnings.
  • Prettier, targeted ESLint, and git diff --check passed.
## Summary Let the browser discover the primary font from server-rendered HTML instead of waiting for stylesheet discovery. - Preload only the regular (400) face of the configured bundled font. - Prefer the configured custom font file when present; emit no hint for an unknown family without a custom file. - Use `as="font"`, `type="font/woff2"`, and anonymous CORS so CSS can reuse the preload. - Leave other weights, fallback fonts, font styling, and `font-display: swap` unchanged. - Include a patch changeset for `@when/web`. This is the fonts-only follow-up to #119. CSS, avatar, and timezone changes remain separate. No PageSpeed score improvement is claimed before deployment and measurement. ## Validation - 35 targeted unit tests passed (font selection, appearance, and the updated admin-health fixture). - Chromium E2E passed with JavaScript disabled: exactly one font preload is present in the initial HTML; the regular face is requested once; no unrelated font family is fetched. - Svelte check: 0 errors and 0 warnings. - Prettier, targeted ESLint, and `git diff --check` passed.
eleith-gitea-agent Bot added 1 commit 2026-11-02 23:07:54 +00:00
perf(web): preload the configured primary font
ci/woodpecker/pr/web Pipeline was successful
dbf71e2fa7
eleith added 1 commit 2026-11-02 23:19:00 +00:00
fix(web): address primary font preload review findings
ci/woodpecker/pr/web Pipeline was successful
ci/woodpecker/push/web Pipeline was successful
4be6755eb8

Independent agent code and readability reviews completed for the original change (dbf71e2), followed by separate verification of the review fixes now pushed as 4be6755.

Findings addressed:

  • Guard bundled-font lookups with Object.hasOwn. Configuration names such as constructor and __proto__ now behave as unknown families rather than crashing page loads. Regression tests added.
  • Strengthen the Chromium E2E: require a successful font response, a loaded regular Noto Sans FontFace, that family in the body's computed style, and a single request. The earlier request-count-only test did not establish successful CSS consumption.
  • Update the existing patch changeset.

Both follow-up reviews reported no remaining actionable code or readability findings.

Revalidation: 37 targeted unit tests and the strengthened Chromium E2E passed; Svelte check reported zero errors/warnings; targeted Prettier, ESLint, and diff checks passed.

Performance limitation remains: earlier font discovery and request reuse are verified, but no improved Lighthouse/PageSpeed score has been measured. This hint does not reduce font bytes or JavaScript blocking time, and can compete with other critical resources; score impact still needs deployment/controlled measurement.

Independent agent code and readability reviews completed for the original change (`dbf71e2`), followed by separate verification of the review fixes now pushed as `4be6755`. Findings addressed: - Guard bundled-font lookups with `Object.hasOwn`. Configuration names such as `constructor` and `__proto__` now behave as unknown families rather than crashing page loads. Regression tests added. - Strengthen the Chromium E2E: require a successful font response, a loaded regular Noto Sans FontFace, that family in the body's computed style, and a single request. The earlier request-count-only test did not establish successful CSS consumption. - Update the existing patch changeset. Both follow-up reviews reported no remaining actionable code or readability findings. Revalidation: 37 targeted unit tests and the strengthened Chromium E2E passed; Svelte check reported zero errors/warnings; targeted Prettier, ESLint, and diff checks passed. Performance limitation remains: earlier font discovery and request reuse are verified, but no improved Lighthouse/PageSpeed score has been measured. This hint does not reduce font bytes or JavaScript blocking time, and can compete with other critical resources; score impact still needs deployment/controlled measurement.
eleith merged commit 4be6755eb8 into main 2026-11-02 23:25:04 +00:00
eleith deleted branch perf/preload-primary-font 2026-11-02 23:25:04 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eleith/when#120