Question presented to candidate: "Lighthouse flags too much JavaScript on our product pages. How do you find out what is in the bundle, and what are your main levers to reduce it in a Next.js app?"
What a strong answer should cover:
- Next.js 16 removed the size and First Load JS columns from
next build; measure with the Turbopack bundle analyzer (next analyzesince 16.4;next experimental-analyzein 16.1 to 16.3, still an alias),@next/bundle-analyzerfor Webpack builds, and Lighthouse. - Biggest lever: keep code in Server Components, which ship no client JavaScript, and push 'use client' down to small leaves.
- Import only what you use: per-function imports or
optimizePackageImportsfor large libraries. - Lazy load heavy client code with next/dynamic or
import()in handlers. - Move third-party scripts to next/script with a late strategy, and keep server-only packages out of client imports.
Clarifying questions expected:
- "Which route and which user flow?" β measure the page that matters, not the whole app.
- "Is the cost in our code or in dependencies?" β the analyzer answers that.
Code / implementation expected: Yes β an import change and the analyzer command.