Code splitting breaks your bundle into smaller chunks that load on demand instead of all at once.
Think: stream one episode, not the whole season.
React.lazy + Suspenseconst SmileyFace = lazy(() => import('./SmileyFace'));<Suspense fallback={<div>Loading...</div>}><SmileyFace /></Suspense>
✔ Component loads only when rendered.
✔ Smaller initial bundle.
✔ Faster startup.
Avoid loading expensive libraries (e.g. Three.js) until needed:
const Globe = lazy(() => import('./Globe'));{showGlobe && (<Suspense fallback={<div>Loading globe...</div>}><Globe /></Suspense>)}
✔ Login page stays fast.
✔ Globe loads only when user requests it
If users almost always open the feature, preload it early:
const preloadGlobe = () => import('./Globe');<label onPointerOver={preloadGlobe} onFocus={preloadGlobe}>
✔ Starts loading before click.
✔ Feels instant
useTransitionAvoid flashing loaders when lazy components load quickly:
startTransition(() => setShowGlobe(true));
✔ Marks UI update as low priority ✔ Keeps interactions smooth
Optional: use spin-delay to prevent flickering loaders.