frontend-bundle-size

Analyze React and Next.js import graphs to reduce bundle size.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/adrian729/skills --skill frontend-bundle-size
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-bundle-size
Source: https://github.com/adrian729/skills/tree/main/.claude/skills/frontend-bundle-size
Command: npx skills add https://github.com/adrian729/skills --skill frontend-bundle-size

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers reduce frontend bundle size and improve load and HMR performance by identifying heavy or unnecessary imports and recommending safer loading patterns.

Core Features & Use Cases

  • Barrel import avoidance: prefer direct module imports to prevent pulling large re-exported libraries into client bundles.
  • Dynamic loading & React.lazy: recommend moving heavy modules behind dynamic import() or React.lazy with Suspense and client-side guards to avoid SSR bundling.
  • Intent-based preloading: suggest preloading on hover, focus, or feature-flag activation to improve perceived performance without inflating initial payloads.
  • Use Case: optimize a React/Next.js app that currently imports large UI libraries like @mui/material or lucide-react to reduce dev boot time, build size, and cold starts.

Quick Start

Ask the skill to analyze a component or import graph and return actionable recommendations to replace barrel imports, add dynamic imports or React.lazy, and implement intent-based preloading.

Frequently Asked Questions about frontend-bundle-size

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

FAQPage Schema
How do I reduce bundle size in a React or Next.js application?

Reduce bundle size in a React or Next.js app by replacing barrel file imports with direct module imports, and moving heavy components behind dynamic import() or React.lazy with client-side SSR guards to prevent bundling.

Why does importing from barrel files increase frontend bundle size?

Importing from barrel files increases frontend bundle size because barrel files re-export entire libraries, forcing bundlers to pull large unused re-exported modules into the client payload instead of just the required components.

What is the best way to lazy load heavy modules in Next.js without breaking SSR?

The best way to lazy load heavy modules in Next.js without breaking SSR is using dynamic import() or React.lazy with Suspense and client-side guards, ensuring the heavy modules are excluded from server-side bundling and loaded on demand.

How do I implement intent-based preloading for dynamic imports?

Implement intent-based preloading for dynamic imports by triggering module fetching on user interactions like hover or focus, or during feature-flag activation, improving perceived performance without inflating the initial payload.

Does code-splitting with React.lazy work for optimizing large UI library imports?

Yes, code-splitting with React.lazy works for optimizing large UI library imports by moving heavy modules like @mui/material behind dynamic import() and replacing barrel imports to reduce dev boot time, build size, and cold starts.

When should I not use dynamic import() for tree-shaking external packages?

You should avoid dynamic import() for tree-shaking when a direct module import is sufficient, as adding unnecessary dynamic splitting for lightweight packages can complicate loading patterns without significantly reducing bundle size.