Skip to content

Load page assets only when needed - #38

Merged
mre merged 1 commit into
mainfrom
perf/lazy-page-assets
Aug 4, 2026
Merged

Load page assets only when needed#38
mre merged 1 commit into
mainfrom
perf/lazy-page-assets

Conversation

@mre

@mre mre commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • extract 55 KB of shared CSS from the 114 KB base template into a cacheable static stylesheet, reducing dynamic base HTML to 34 KB
  • self-host one 47 KB Inter variable WOFF2 for the used 400-700 range; remove Google Fonts entirely
  • bundle and self-host CodeMirror, Lezer, Rust highlighting, and Vim mode as split, shared local chunks; remove the global esm.sh import map and all direct esm.sh imports
  • add a pinned npm lockfile and CI drift check for generated bundles; production serves checked-in assets and does not require Node
  • load quiz.js only for the quiz chapter
  • fetch canvas-confetti only after a successful run requests the celebration
  • defer the read-only CodeMirror solution viewer until a solution is revealed
  • skip loading the Rust prose parser on pages without prose code blocks

Observed impact

  • base.html: 114,158 bytes -> 34,341 bytes
  • initial page loads make no requests to Google Fonts, fonts.gstatic.com, or esm.sh
  • Inter is served as one local variable font covering 400-700
  • quiz.js is absent from dashboard, normal chapters, and tour
  • canvas-confetti is absent from initial page requests
  • readonly editor dependencies are absent before solution reveal

Validation

  • cargo fmt --all --check
  • cargo clippy --locked --lib --bins -- -D warnings
  • cargo test --locked --lib --bins
  • ./scripts/check-examples.sh
  • REQUIRE_COMPLETE=1 ./scripts/check-solutions.sh (75/75)
  • npm audit --omit=dev (0 vulnerabilities)
  • rebuilt bundles and syntax-checked every generated JS file
  • browser smoke test: dashboard, normal exercise, tour, cheatsheet, settings, admin, editable editors, and lazy read-only solution viewer
  • browser network test: all local font/dist requests 200; zero Google Fonts or esm.sh requests

@mre
mre merged commit 137bfea into main Aug 4, 2026
4 checks passed
@mre
mre deleted the perf/lazy-page-assets branch August 4, 2026 14:58
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