Skip to content
Back to skills

Bundle Size Reduction

ASecurity

Analyzes a JavaScript bundle, splits code and replaces heavy dependencies, and reports byte counts before and after every change it makes.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agentsjavascriptjavaapi

Works with

  • api

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill bundle-size-reduction --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bundle Size Reduction?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Bundle Size Reduction
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-bundle-size-reduction/badge)](https://www.skillsdirectory.com/skills/workspace-templates-bundle-size-reduction)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bundle-size-reduction
description: Analyzes a JavaScript bundle, splits code and replaces heavy dependencies, and reports byte counts before and after every change it makes.
---

# Bundle size reduction

Numbers first. Do not change anything until you have a baseline and a ranked list.

## Steps

1. Build for production and record total, gzip and brotli size per chunk. Generate a treemap with the project's bundler (`npx vite-bundle-visualizer`, `webpack-bundle-analyzer`, `npx source-map-explorer dist/*.js`, or `ANALYZE=true` for Next).
2. List the ten largest modules and who imports them. Look specifically for: full-library imports (`import _ from 'lodash'`, `import * as`), moment or other locale-heavy date code, duplicate versions of one package (`npm ls <pkg>`), polyfills for browsers you do not support, and icon sets imported whole.
3. Fix in order of bytes saved:
   - Replace heavy libraries with native APIs or small ones (`Intl.DateTimeFormat`, `structuredClone`, `date-fns` named imports).
   - Use named, tree-shakeable imports and check `sideEffects: false` in the package.
   - Dedupe versions with the package manager.
   - Lazy-load what is not needed on first paint: routes, modals, charts, editors, with `import()`.
4. Rebuild after every change and note the delta.
5. Check the result still works: run the tests and load the lazy parts once.

## Rules

- Do not remove a dependency still used elsewhere. Search before you delete.
- Never trade a size win for broken browser support listed in the project's browserslist.
- Stop when a change saves under 2 KB gzipped.

## Report

A table of change, bytes before, bytes after. Then what remains and why you left it.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.