bundle-analysis

Analyze JavaScript bundle sizes and identify optimization opportunities for Next.js apps.

21|2|Updated Nov 5, 2023
One-click install
npx skills add https://github.com/sgcarstrends/sgcarstrends --skill bundle-analysis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bundle-analysis
Source: https://github.com/sgcarstrends/sgcarstrends/tree/main/.claude/skills/bundle-analysis
Command: npx skills add https://github.com/sgcarstrends/sgcarstrends --skill bundle-analysis

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill analyzes JavaScript bundle sizes and identifies optimization opportunities for Next.js apps.

Core Features & Use Cases

  • Bundle analyzer setup for Next.js.
  • Optimization patterns: dynamic imports, tree-shaking, and code splitting.
  • Guidance on reducing route and vendor chunk sizes.

Quick Start

Run the bundle analyzer and apply a dynamic import to a large component.

Frequently Asked Questions about bundle-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce JavaScript bundle size in Next.js applications?

Reduce JavaScript bundle size by setting up a bundle analyzer tool, then apply code-splitting, tree-shaking, and dynamic imports to eliminate unused code and defer non-critical components. Next.js bundle analyzer visualizes chunk composition so you can target the largest contributors to load time.

What causes slow initial page loads and how do I fix bundle size issues?

Large bundles over 500KB and unoptimized vendor chunks increase First Contentful Paint and Time to Interactive. Fix by removing duplicate dependencies, implementing selective dependency imports, and splitting code so only required JavaScript loads per route.

Can I use dynamic imports and code splitting with Next.js?

Yes. Next.js supports dynamic imports for lazy-loading components and automatic code-splitting by route. This defers bundle delivery, reducing initial load and enabling faster Time to Interactive on first page render.

How do I identify duplicate dependencies affecting my bundle?

Use a bundle analyzer to inspect your client and server reports, which reveal duplicate packages and vendor chunk bloat. Once identified, apply selective imports and tree-shaking configuration to eliminate redundancy and shrink bundle output.

What's the best approach to optimize production builds for performance?

Set up bundling analysis tooling with environment configuration, analyze route and vendor chunk composition, then implement tree-shaking, code-splitting, and dynamic imports. Target specific metrics like bundle size thresholds to achieve faster page delivery.

Do I need bundle analysis for web applications outside Next.js?

Bundle analysis applies to general web applications beyond Next.js. Any application with large bundles, slow initial loads, or high First Contentful Paint can benefit from setting up bundling analysis tooling and applying code-splitting and tree-shaking patterns.