Large JavaScript bundles
Every kilobyte of JavaScript has to be downloaded, parsed, compiled, and executed before the page is interactive — and on a mid-range phone that work is many times slower than on your laptop. When one bundle ships the whole app up front, first interaction is delayed for everyone. AI-built apps balloon here by importing entire libraries for one helper and never code-splitting by route.
Symptoms
How VibeCheck catches it
In your widget · Problems
To your coding agent · MCP
The same string in your widget and in your agent’s context — no screenshot, no copy-paste.
Root causes
The fix
Split code so each route and heavy component loads on demand, import only what you use so tree-shaking can drop the rest, and run a bundle analyzer to find the biggest offenders. Ensure the server sends gzip/brotli-compressed assets.
- Run a bundle analyzer to identify the largest chunks and dependencies
- Code-split by route and lazy-load heavy, non-critical components
- Replace whole-library imports with named/deep imports and remove duplicates
// ✗ pulls the whole library into the bundle
import _ from 'lodash'
// ✓ only debounce ships
import debounce from 'lodash-es/debounce'FAQ
- Why is the threshold higher in development?
- Dev bundles are unminified and include source maps and HMR runtime, so they’re legitimately large. VibeCheck raises the bar to 500KB on localhost and uses 100KB for production, where the size actually ships to users.
- What’s the fastest win?
- Route-level code splitting. It ensures a user landing on one page doesn’t download the code for every other page. After that, lazy-load the heaviest individual components (editors, charts, maps).
- How do I find what’s making the bundle big?
- Run a bundle analyzer (
@next/bundle-analyzer,rollup-plugin-visualizer, orsource-map-explorer). It shows a treemap of every module so you can spot an oversized dependency or an accidental whole-library import.