Reduce JavaScript bundle size
Measures a web app's JavaScript bundles, finds the largest avoidable contributors, and shrinks them with verified changes ranked by bytes saved. Use when page load is slow or a size budget is blown.
JavaScript is the most expensive byte on the web: it has to be downloaded, parsed and executed before the page responds. Most bundles carry avoidable weight: whole libraries imported for one function, duplicate versions, code for routes the user has not visited, and polyfills for browsers the app does not support. Savings only count when measured on the production build, compressed.
Reduce the bundle size of: Budget: .
- Identify the bundler and build. Produce a production build and record the baseline: the initial JavaScript loaded by the target page and the total, both compressed (gzip or brotli, whichever the server uses).
- Generate a bundle analysis with the tool that fits the bundler (for example a bundle visualizer plugin, the bundler's stats output, or source-map-explorer).
- List the largest contributors and classify each: needed on first load, needed only later or on another route, duplicated, imported wholesale but used partly, polyfill or dead code that was not tree-shaken, or a large asset inlined into JavaScript.
- Fix in order of bytes saved per effort: lazy-load routes and heavy components with dynamic imports, switch to per-function or ESM imports, deduplicate versions, drop polyfills outside the supported browser list, and mark side-effect-free packages so they tree-shake.
- Rebuild after each change and record the size difference. Run the tests and check that the affected pages still work.
- Do not remove features or change behaviour to save bytes.
- Replacing a dependency with another is a proposal, not a change, unless the swap is trivial and fully covered by tests.
- Report compressed sizes from real builds. Never estimate savings you did not build.
- Keep lazy-loading changes from causing layout shift or an empty screen; add a loading state where one is needed.
- Before saying the work is done, run the check that proves it (tests, build, type check or the command the user gave) and report the real result.
- If you could not run a check, say so plainly and say which one.
- Do only what was asked. If you notice something else worth changing, mention it in one line at the end instead of changing it.
- Keep the change as small as it can be while still being correct.
Result
One line: initial JavaScript before and after (compressed), total before and after, and whether the budget is met.
Biggest contributors
Table: module or package, compressed size, classification.
Changes made
Numbered: change — bytes saved (compressed) — verification.
Proposals not applied
Bullets: proposal — expected saving as a hypothesis — trade-off.
How to measure again
The exact commands.
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Software engineering
- category
- Performance
- level
- Intermediate
- made for
- Frontend engineer, Full-stack engineer
- needs
- repo-read, file-write, shell
- risk
- runs-commands
- version
- v1.0.1 · experimental
- reviewed
- 2026-10-02
- aliases
- perf-bundle
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md
use in
npx @hermes-hq/hodios install reduce-bundle-size --target claude-codenpx skills add hermes-hq/hodios-dist --skill reduce-bundle-size -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-software-engineering@hodiosThe plugin brings every entry in this domain at once.
more in performance
All of PerformanceFix N+1 queries
Finds N+1 database queries behind an endpoint, page or job by counting real queries, fixes them with eager loading or batching, and adds a query-count test so they do not return.
fix-n-plus-one-queriesProfile and speed up a hot path
Measures a slow operation, profiles where the time goes, and makes it faster one verified change at a time, with before-and-after numbers. Use when an endpoint, command or function is too slow.
profile-hot-pathAnalyse load test results
Interprets k6, JMeter, Locust or Gatling results, finding the knee where latency climbs, separating load-generator limits from server saturation, and judging the pass criteria.
analyze-load-test-resultsFind a memory leak
Finds a memory leak from heap snapshots, memory metrics and code, naming the retaining path and the minimal fix with a regression check. Use when memory grows until a process is killed or restarted.
find-memory-leakFix slow or excessive React re-renders
Finds why React components re-render too often or render slowly, measures before changing anything, then fixes the cause with state changes or targeted memoisation. Use when a React UI feels laggy.
fix-react-rerendersHit a game frame budget
Diagnoses frame drops against a 16.6 or 33.3 ms budget from profiler captures, separating CPU from GPU bound, and ranks fixes by milliseconds saved per effort. Use before shipping on weak hardware.
hit-game-frame-budget