- All Courses
- React Performance Engineering
- Loading Performance
- Code splitting and lazy boundaries
Code splitting and lazy boundaries
A dynamic import becomes a separate chunk that is fetched only when the code is first needed.
Overview
Ship the code for this screen, not every screen
A dynamic import becomes a separate chunk that is fetched only when the code is first needed. Routes are the natural boundary; the second-best is anything behind a rare interaction, like an editor or a chart library inside a modal.
Every boundary needs a fallback, and the fallback should reserve the space the real component will occupy or you have traded a slow load for a layout shift.
Over-splitting has its own cost. Dozens of tiny chunks mean dozens of requests and a waterfall of dependent loads, which is often slower than one reasonably sized bundle.
In this lesson you will:
- Split along routes and rare interactions
- Give every lazy boundary a sensible fallback
- Avoid splitting so finely that you add round trips
Resources
Notes are not saved yet — they clear when you leave this page.
Concurrent rendering with useTransition
8m
Bundle analysis
3m