Performance: Code splitting and lazy loading
HIGH IMPACT
This concept affects page load speed by reducing initial bundle size and deferring non-critical code loading.
import { lazy, Suspense } from 'react'; const BigComponent = lazy(() => import('./BigComponent')); export default function Page() { return <Suspense fallback={<div>Loading...</div>}><BigComponent /></Suspense>; }
import { BigComponent } from './BigComponent'; export default function Page() { return <BigComponent />; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single large bundle | Minimal | Single large reflow | High paint cost due to blocking | [X] Bad |
| Code splitting with lazy loading | Minimal | Multiple small reflows on demand | Lower paint cost, faster initial render | [OK] Good |