hermes

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.

context

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.

task

Reduce the bundle size of: Budget: .

  1. 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).
  2. 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).
  3. 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.
  4. 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.
  5. Rebuild after each change and record the size difference. Run the tests and check that the affected pages still work.
constraints
  • 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.
output format

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.0 · experimental
reviewed
2026-10-02
works in
Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md

Edit on GitHubReport a problem

use in

Hodios CLI
npx @hermes-hq/hodios install reduce-bundle-size --target claude-code
Agent Skills
npx skills add hermes-hq/hodios-dist --skill reduce-bundle-size -a claude-code
Add the Hodios marketplace (once)
claude plugin marketplace add hermes-hq/hodios-dist
Install the software-engineering plugin
claude plugin install hodios-software-engineering@hodios

The plugin brings every entry in this domain at once.

more in performance

All of Performance
PromptPerformance

Fix 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-queries
PromptPerformance

Profile 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-path
PromptPerformance

Find 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-leak
PromptPerformance

Improve Core Web Vitals

Diagnoses poor Core Web Vitals (LCP, INP, CLS) from a Lighthouse, field-data or trace report and ranks fixes by expected improvement. Use when a page fails the vitals thresholds.

improve-web-vitals
PromptPerformance

Optimise a slow SQL query

Speeds up a slow SQL query from its execution plan, proposing rewrites and indexes with expected gains and their write-cost trade-offs. Use when one query dominates latency or database load.

optimize-sql-query
PersonaPerformance

Performance engineer

Acts as a performance engineer who profiles before optimising, changes one thing at a time and reports gains with numbers and variance. Use for latency, throughput or memory work.

performance-engineer