Repository navigation
perf(assets): shrink gameplay image payload from ~10 MB to ~90 KB - #28
Merged
merlik787-droi merged 3 commits intoAug 27, 2026
Merged
merlik787-droi merged 3 commits into
merlik787-droi merged 3 commits into
Conversation
Re-encode the eight GameHeader icons, the timer icon, and the hero image to WebP at ~2x their rendered size (icons: 80px, hero: 1400px), cutting the gameplay bundle from ~10 MB of uncompressed PNGs to ~90 KB total. Adds a sharp-based optimizer (npm run optimize:assets), a 250 KB asset size budget enforced at build time and in CI (npm run check:assets), and documents the policy in ASSET_POLICY.md. Lazy-loads the hero image and async-decodes header icons. Removes unused multi-MB contributor images that would trip the new budget. Closes Riddlrealm#13 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
main's test suite and build are currently broken by a bad merge: Dashboard references an undefined `leaderboardView` (and an unused mock import), and the AuthService suite leaks localStorage between cases so a token persisted by an earlier test masks a fail-closed assertion. Wire Dashboard back to the live useLeaderboard hook, drop the unused import, and clear localStorage per test. These fixes are required for CI (npm test) to pass at all, so they ship alongside the asset work to keep this PR's checks green. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
The committed lockfile was missing entries for the @vitest/coverage-v8 dependency subtree (make-dir, html-escaper, semver), which made `npm ci` fail with an out-of-sync error in CI. Regenerate with `npm install` and commit the completed tree; `npm ci` now installs cleanly. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
merlik787-droi
approved these changes
Aug 27, 2026
5 tasks
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.
Closes #13
Summary
The gameplay header bundled ~10 MB of uncompressed PNGs (each icon ~1 MB, rendered at 40 px) plus a 2 MB hero image, dwarfing the ~116 KB gzipped JS bundle. This PR re-encodes those images to WebP at ~2× their rendered size, adds an enforced asset budget so it can't regress, and documents the policy.
What changed
Assets — all images re-encoded to WebP at ~2× rendered size (see
scripts/optimize-assets.mjs):clock.png(timer)hero-image.pnghero-image.webpat 75.7 KB.contributor*.jpgfiles (not referenced anywhere) that would otherwise trip the new budget.Delivery —
hero-imagenow usesloading="lazy"+decoding="async"(it is hidden on mobile; browsers still fetch it eagerly when in the initial viewport). Header icons gotdecoding="async".Guard — new
scripts/check-asset-size.mjsfails when any raster asset insrc/assets/orpublic/exceeds 250 KB. Wired intonpm run buildand as a dedicated CI step in.github/workflows/ci.yml.Docs — new
ASSET_POLICY.md(formats, 250 KB budget, ~2× sizing rule, lazy-loading rule, new-image checklist), linked from the README.Tooling —
sharpadded as a devDependency;npm run optimize:assetsre-runs the conversion.CI note
main was already failing
npm test(3 failures) andnpm run builddue to a bad merge:Dashboard.tsxreferences an undefinedleaderboardView, and theAuthServicesuite leakslocalStoragebetween tests. Since this PR's CI runs the full suite, it includes a small second commit fixing both (useLeaderboardwired back intoDashboard, unused import dropped,localStoragecleared per test). CI is green with these included.Verification
npm test— 51/51 passnpm run lint— cleannpm run build— succeeds; no asset indist/assetsexceeds 250 KBnpm run check:assets— passes