Skip to the page

Web performance · Scenario

Code splitting, lazy loading and bundle size

The interviewer asks

Your main bundle is 1.8 MB. How do you bring it down, and how do you stop it from creeping back?

Then

Follow-ups the interviewer asks next

  1. Route-level vs component-level splitting (import(), React.lazy).
  2. Analysing with a bundle analyzer / source-map-explorer; spotting duplicate dependencies.
  3. Performance budgets in CI (size-limit).
  4. Prefetching the next route's chunk on hover or idle.

The answer

What a strong answer covers

  • Measure first; remove or replace heavy libraries (moment → date-fns/Temporal, lodash → per-method imports)
  • Tree shaking requires ESM and side-effect-free modules
  • Defer third-party scripts; ship modern bundles to modern browsers
  • Budgets plus PR checks to prevent regressions

The red pen

Common traps

Avoid:splitting into hundreds of tiny chunks (waterfalls); lazy-loading above-the-fold UI.

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview