Skip to the page

Images, fonts, scripts and SEO · mid

next/image, next/font and next/script

next/image serves resized modern-format images with reserved space and lazy loading, next/font self-hosts fonts with fallback metrics so text does not shift, and next/script controls when third-party scripts load; together they protect LCP, CLS and INP.

The notes

What you must know

  • Images: give width/height (or fill + a sized parent) so space is reserved (no CLS); add sizes with responsive layouts so phones do not download desktop images.
  • Images are lazy by default. For the LCP image: in Next 16 the priority prop is deprecated; use preload (adds a <link rel="preload">) or, in most cases, loading="eager" / fetchPriority="high".
  • Next 16 image defaults: qualities is [75] (other quality values are coerced), minimumCacheTTL 4 hours, size 16 removed from imageSizes, local IPs blocked (dangerouslyAllowLocalIP), max 3 redirects, localPatterns needed for local src with query strings. images.domains is deprecated: use remotePatterns.
  • Self-hosting: optimisation uses sharp on your server (CPU and memory); a CDN loader can take that load.
  • next/font/google and next/font/local: fonts are downloaded at build and served from your domain (no browser requests to Google), with automatic fallback metrics so swapping fonts does not shift layout. Prefer variable fonts; set subsets; define in the root layout; expose as a CSS variable for Tailwind.
  • next/script strategies: beforeInteractive (root layout only, critical), afterInteractive (default), lazyOnload (idle). onLoad/onReady need a Client Component. Heavy third-party scripts hurt INP.
  • Measure with field data (CrUX/RUM): LCP <= 2.5 s, INP <= 200 ms, CLS <= 0.1 at the 75th percentile.

The red pen

Common traps: mistake → fix

  • Mistake: "Use priority on the hero"

    Fix: deprecated in Next 16; use preload, or loading="eager"/fetchPriority="high".

  • Mistake: "Lazy-load every image including the hero"

    Fix: delays LCP.

  • Mistake: "Omit sizes with fill"

    Fix: the browser may pick a far larger image than needed.

Easy to hard

Questions interviewers ask, easy to hard

  1. Our homepage LCP element is a banner image. How do you use next/image and next/font to improve LCP and CLS?
  2. What changed in next/image defaults and props in Next 16?
  3. Remote images: remotePatterns vs domains?
  4. How does next/font prevent layout shift?
  5. Where should a chat widget script load?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

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

Start your free interview