Question presented to candidate: "Our Lighthouse report shows a slow LCP and some layout shift on the landing page. How would next/image and next/font help, and which settings would you change?"
What a strong answer should cover:
- LCP (Largest Contentful Paint) is usually the hero image or heading: preload the hero image and serve it at the right size and format.
- CLS (Cumulative Layout Shift) comes from images without reserved space and fonts that swap to a different size.
- next/image reserves space from width and height, lazy-loads below-the-fold images and serves WebP or AVIF at the right width.
- next/font self-hosts and preloads fonts and adds a size-adjusted fallback so the swap does not shift text.
- In Next.js 16 use
preload(orfetchPriority="high") instead of the deprecatedpriorityfor the LCP image.
Clarifying questions expected:
- "What is the LCP element on this page?" — the fix differs for an image or a text block.
- "Where does the shift happen?" — images, fonts, or late-inserted content like banners.
Code / implementation expected: Yes — a landing page hero using both.