Make a web game download faster by shrinking its images and audio and finding unused files, without breaking it. Converts PNG/JPG to WebP (lossless for pixel art), re-encodes WAV/FLAC and oversized MP3/OGG to small MP3 (optionally OGG too), can scale down huge images, updates every reference in the HTML/JS/CSS/JSON, backs up originals, and lists files nothing uses. Use for "game loads slowly", ...
Download skill (.zip) Files on GitHubWeb asset shrinker
1. Dry run first (changes nothing)
python3 <skill>/scripts/shrink-assets.py www
python3 <skill>/scripts/shrink-assets.py www --max-size 2048 # also scale down giant images
Shows each planned conversion with before and after sizes, files it left alone and why, and files nothing in the code names (“Unused?”). Tell the user the total saving in one line, for example “I can cut the game from 38 MB to 9 MB, mostly the music.”
2. Apply
python3 <skill>/scripts/shrink-assets.py www --apply # + --ogg to also write .ogg twins
- Originals of every changed file go into
/tmp/asset-backup-*.tar.gz(the path is printed). Restore one with:tar -xzf <backup> -C www <path>. - References are updated in every
.html/.js/.css/.json/.atlas/.fnt/.xml/.svg/.tmjfile, so texture-atlas JSON and Tiled maps keep working. - Run it in the source / build folder the game is built from, not only in an exported copy, or the next
build brings the big files back. For bundlers (Vite and so on), run it on
public/orsrc/assets/, then rebuild.
| Asset | Becomes | Notes |
|---|---|---|
| PNG/JPG with ≤256 colors (pixel art, flat UI) | WebP lossless | Pixel-exact |
| Other PNG/JPG over 8 KB | WebP quality 82 (--quality) |
Keeps transparency |
| WAV / AIFF / FLAC | MP3. Sounds ≤20 s: 128 kbps mono; music: 96 kbps stereo | --sfx-kbps, --music-kbps |
| MP3 / OGG / M4A with a much higher bitrate | Re-encoded to the same targets | Only if it saves ≥10% (--min-saving) |
| Fonts over 100 KB | Listed only | Suggest WOFF2 |
WebP works in every current browser, including Safari 14+. MP3 plays everywhere, so it’s the safe
default. Add --ogg when the game chooses its format in code.
3. Safety rules (built in, but say them)
- Only files named literally in the code are converted. Files loaded with built-up names
(
"lvl" + n + ".png") are listed but not touched. Convert those by hand and update the code that builds the name. - Unused files are only deleted with
--apply --remove-unused, and only after you’ve checked the list with the user. Dynamic paths make them look unused. Same-name twins (theme.oggnext to a usedtheme.mp3) count as used. --skip 'favicon|og-image|cover'leaves chosen files alone.index.html,CREDITS.md,build-info.json, manifests, and favicons are never touched.- Engines that pick files by extension in config (for example Phaser
this.load.audio('jump', ['jump.ogg','jump.mp3'])): check the loader lines after converting.
4. Check
- Run the game in the preview and make sure every image and sound still loads (read_preview_console for 404s).
- Pixel art: look closely. It should be identical (lossless). Painted art at q82 should look the same.
If the user sees a difference, re-run with
--quality 90from the backup. - If the bash-web-game-checkup skill is installed, run it again to confirm the size warnings are gone.
Other ways to load faster
These are code changes, so suggest them and do them when asked:
- Load music and later levels after the game starts. Show a loading bar for the first batch.
- Combine many small sprites into a sprite sheet (fewer files, which matters on itch.io’s 1,000-file limit).
- Lower the resolution of backgrounds that are drawn scaled up anyway.
- For long music, 64 kbps mono is often fine for background loops.