Images, Fonts and Critical Rendering Path

Serve responsive modern images, load fonts without layout shift, and prioritise the resources needed for the first paint.

Intermediate · about 4 hours · difficulty 3/5

Learn first: Core Web Vitals and Performance Metrics

Images are usually the heaviest bytes on a page, and the LCP element is an image on most sites. Fonts and CSS block text from appearing. Getting these right is often the quickest performance win.

Images

  • Use modern formats: AVIF or WebP with fallbacks via <picture>.
  • Serve the right size with srcset and sizes so phones do not download desktop images.
  • Always set width and height (or aspect-ratio) to prevent layout shift.
  • loading="lazy" for below-the-fold images, but never lazy-load the LCP image. Give the hero image fetchpriority="high".
  • Use SVG for icons and logos, and an image CDN or framework image component (Next.js <Image>) to automate resizing.

Fonts

  • Prefer WOFF2, subset to the characters you need, and self-host or use a reliable provider.
  • font-display: swap shows fallback text immediately; tune fallback metrics (size-adjust) to reduce the shift when the web font arrives.
  • Preload the one or two most important font files; use fewer weights, or a variable font.
  • System font stacks cost nothing.

Critical rendering path

  • CSS is render-blocking: keep critical CSS small, inline it if needed, and load the rest efficiently.
  • Put non-critical scripts behind defer.
  • Use preconnect for important third-party origins.
  • Reduce request chains: the browser should discover the LCP resource in the initial HTML, not after JavaScript runs.

Good enough to move on

You can turn a page with a large hero image and custom fonts into one with a fast LCP and near-zero CLS, and explain each change using the Network and Performance panels.

Key concepts

  • Modern image formats: AVIF and WebP
  • Responsive images with srcset and sizes
  • Lazy loading and fetchpriority
  • Preventing layout shift
  • Web font loading and font-display
  • Render-blocking CSS and critical CSS
  • preconnect and preload hints
  • Image CDNs and framework image components

Mini project

Optimise a landing page: convert images to AVIF/WebP with srcset, fix the LCP image priority, add dimensions everywhere, subset and preload the main font, and bring CLS below 0.05.

Check yourself

Why does adding loading="lazy" to the hero image make LCP worse?

Free resources