The Bundle Size vs Request Count Tradeoff
You'll learn: Why splitting code into many small chunks improves initial load but may slow down overall page performance.
The Core Dilemma
When you code split aggressively, you create a tradeoff: smaller initial bundles mean more HTTP requests to fetch everything the user needs.
Think of it like grocery shopping. You could make one trip carrying heavy bags (large bundle, one request), or make ten trips carrying light bags (many small chunks, many requests). The first trip starts slower but finishes faster overall. The second starts quickly but takes longer to complete.
Why This Matters
Each code-split chunk requires a separate network request. While your initial bundle might be tiny (great for first paint!), the browser must:
- Request chunk A
- Parse and discover it needs chunk B
- Request chunk B
- Parse and discover it needs chunk C
- And so on...
This creates request waterfalls that can actually slow down the complete page load, especially on slower networks where request overhead matters.
Finding Balance
The sweet spot depends on your app:
- Too few chunks: Large initial bundle, slow first load
- Too many chunks: Fast initial load, but slow complete experience due to waterfall requests
Route-level splitting usually hits the balance well—each route is a reasonably-sized chunk, and users rarely need all routes at once.
Key Takeaway: Code splitting isn't free—each new chunk adds a network request, so split strategically at natural boundaries (routes, large features) rather than splitting every component into its own file.