Skip to content
Skills Library
Programming · Analysis

bundle-analyzer

/bundle-analyzer

JavaScript/TypeScript bundle size analysis, tree-shaking audit, and code splitting recommendations. Identifies heavy dependencies, duplicate packages, unused imports, and suggests dynamic imports and lazy loading. Use when bundle is too large, Lighthouse score is low, or user wants to optimize web app loading performance.

Licence
MIT
Last repository change
16.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 16.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

JavaScript/TypeScript bundle size analysis, tree-shaking audit, and code splitting recommendations. Identifies heavy dependencies, duplicate packages, unused imports, and suggests dynamic imports and lazy loading. Use when bundle is too large, Lighthouse score is low, or user wants to optimize web app loading performance.

Original author description

JavaScript/TypeScript bundle size analysis, tree-shaking audit, and code splitting recommendations. Identifies heavy dependencies, duplicate packages, unused imports, and suggests dynamic imports and lazy loading. Use when bundle is too large, Lighthouse score is low, or user wants to optimize web app loading performance.

How it works

  1. Quick Start
  2. What Gets Analyzed
  3. Workflow
  4. Output Format
  5. Common Fixes
  6. Size Budgets (reference)
Original SKILL.md headings · 113 lines, 536 words
SKILL.md preview
---
name: bundle-analyzer
description: JavaScript/TypeScript bundle size analysis, tree-shaking audit, and code splitting recommendations. Identifies heavy dependencies, duplicate packages, unused imports, and suggests dynamic imports and lazy loading. Use when bundle is too large, Lighthouse score is low, or user wants to optimize web app loading performance.
---

# Bundle Analyzer

Cut your JS bundle. Faster page loads, better Core Web Vitals.

## Quick Start

```
/bundle-analyzer                  — analyze current project bundle
/bundle-analyzer --why lodash     — trace why a dep is included
/bundle-analyzer --alternatives   — find lighter alternatives to heavy deps
/bundle-analyzer --budget 200kb   — check against size budget
/bundle-analyzer --diff           — compare bundle size before/after change
```

## What Gets Analyzed

- **Total bundle size** (gzipped vs raw)
- **Chunk composition** (which routes include what)
- **Duplicate packages** (same lib at different versions)
- **Side-effect imports** (prevents tree-shaking)
- **Dynamic import opportunities** (code-split candidates)
- **Unused exports** (dead exports still in bundle)
- **Heavy dependencies** (sorted by size contribution)

## Workflow

Claude will:
1. Run `npx vite-bundle-visualizer` / `npx @next/bundle-analyzer` / `npx webpack-bundle-analyzer`
2. Parse stats JSON
3. List top 20 largest modules
4. Identify duplicate packages (e.g., lodash + lodash-es)
5. Flag non-tree-shakeable side-effect imports
6. Detect unneeded full library imports (`import _ from 'lodash'`)
7. Recommend: dynamic imports, lighter alternatives, CDN externals

## Output Format

```
BUNDLE ANALYSIS — 2026-06-14
==============================
Total:  1.24 MB raw  |  342 KB gzip
Budget: 200 KB gzip  ❌ (over by 142 KB)

TOP MODULES BY SIZE
  moment.js          94 KB  ← replace with date-fns (tree-shakeable)
  lodash             72 KB  ← import specific functions, not full bundle
  @mui/icons-material 68 KB ← only 3 icons used; import individually
  react-pdf          55 KB  ← load dynamically (only used in /reports)

DUPLICATE PACKAGES
  ⚠ react@18.2.0 + react@17.0.2 (from old-dep peer requirement)
  ⚠ axios@0.27 + axios@1.4 (from two different SDKs)

CODE SPLITTING OPPORTUNITIES
  /admin dashboard — 180 KB (never shown to non-admins)
  PDF generator    — 55 KB (used only on /reports route)
  Charts           — 44 KB (used only on /analytics route)

QUICK WINS (estimated savings: 210 KB gzip)
  1. Replace moment.js → date-fns               → -61 KB
  2. Use individual MUI icon imports             → -62 KB
  3. Dynamic import for react-pdf               → -38 KB (deferred)
  4. Deduplicate lodash versions                → -49 KB
```

## Common Fixes

### Heavy library → lighter alternative

| Replace | With | Savings |
|---------|------|---------|
| `moment` | `date-fns` or `dayjs` | ~90 KB |
| `lodash` | Native ES6 methods | ~70 KB |
| `axios` | `ky` or native `fetch` | ~40 KB |
| `@mui/icons` (full) | Individual icon imports | ~60 KB |
| `chart.js` | `uplot` or `lightweight-charts` | ~100 KB |

### Dynamic import (code splitting)
```typescript
// ❌ always in bundle
import { PDFViewer } from 'react-pdf'

// ✅ only loaded when needed
const PDFViewer = dynamic(() => import('react-pdf').then(m => m.PDFViewer), {
  loading: () => <Spinner />,
  ssr: false,
})
```

### Tree-shakeable import
```typescript
// ❌ full lodash bundle
import _ from 'lodash'
const sorted = _.sortBy(arr, 'name')

// ✅ only imports sortBy
import sortBy from 'lodash/sortBy'
const sorted = sortBy(arr, 'name')

// ✅✅ native (zero bundle cost)
const sorted = [...arr].sort((a, b) => a.name.localeCompare(b.name))
```

## Size Budgets (reference)

| Page Type | Target (gzip) | Max (gzip) |
|-----------|---------------|------------|
| Landing page | <50 KB | 100 KB |
| App shell | <100 KB | 200 KB |
| Feature page | <50 KB incremental | 100 KB |
| Admin/internal | <300 KB | 500 KB |
Files in this package (2)
  • SKILL.md 4 KB
  • plugin.json 1 KB

Versions

The database has no other skills named bundle-analyzer.

Database snapshot: 13.11.2026 · package version c5e9141a7adc (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 84analyze-bundle
    Analyze web application bundle size to find what's making it large and how to shrink it. Always use this skill whenever the user says "analyze the bundle", "what's making my bundle large", "bundle size analysis", "check my webpack output", "why is my app so big", "find heavy…
  • 90bundle-size
    Shrink JavaScript bundles by analyzing what ships, enabling real tree shaking, splitting heavy code, and putting the dependency list on a diet. Use when the initial JS payload is large, slow to parse, or growing unchecked.
  • 100performance-optimization
    Optimize application performance for speed, efficiency, and scalability. Use when improving page load times, reducing bundle size, optimizing database queries, or fixing performance bottlenecks. Handles React optimization, lazy loading, caching, code splitting, and profiling.
  • 100pf-chatbot-bundle-audit
    Audit PatternFly ChatBot imports for tree-shaking opportunities. Use when optimizing ChatBot bundle size or after upgrading @patternfly/chatbot.
  • 100audit-bundle-size
    Analyse and shrink a web app's JavaScript bundle. Use when "reduce bundle size", "code splitting", "slow initial load", or "why is the bundle so big". Runtime → audit-performance.
  • 100perf-web-optimization
    Optimize web performance: bundle size, images, caching, lazy loading, and overall page speed. Use when site is slow, reducing bundle size, fixing layout shifts, improving Time to Interactive, or optimizing for Lighthouse scores. Triggers on: web performance, bundle size, page…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.