Concurrent React and Suspense · mid
Code splitting with lazy and Suspense
Code splitting moves code the first screen does not need into separate chunks loaded with dynamic import(); in React, lazy(() => import("./Chart")) plus a <Suspense> boundary loads a component only when it renders.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
const Chart = lazy(() => import("./Chart"))(the module must default-export the component). Render it inside<Suspense fallback={...}>.- Split by route first, then heavy widgets that are below the fold or behind an interaction (charts, rich editors, maps, modals).
- Do not lazy-load above-the-fold or LCP content; it delays it.
- Prefetch likely next chunks (on hover, on idle, or when visible) to avoid a spinner; avoid waterfalls of lazy chunks that load one after another.
- Bundle analysis: find duplicate libraries, big date/lodash imports, barrel files that defeat tree shaking, unnecessary polyfills. Next.js has
optimizePackageImports,next/dynamic, and the Turbopack Bundle Analyzer (16.1+, much improved in 16.4). - Place Suspense boundaries around meaningful sections so one loading chunk does not blank the page.
- Measure LCP and INP before and after; smaller JavaScript also means less hydration work.
The red pen
Common traps: mistake → fix
Mistake: "Lazy-load everything"
Fix: above-the-fold lazy loading hurts LCP and causes spinners.
Mistake: "Named imports are always tree-shaken"
Fix: barrel files and side effects can pull in the whole library.
Mistake: "
React.lazyworks for named exports directly"Fix: it expects a default export (re-export or map the module).
Easy to hard
Questions interviewers ask, easy to hard
- Our initial JS is 1.8 MB. How do you cut it?
- Where do you put the Suspense boundary, and what does a spinner cost in UX?
- How do you prefetch a lazy chunk?
- Why might a named import pull in a whole library?
- What does
next/dynamicadd on top ofReact.lazy?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.