Image size, format and font loading.
Images and fonts decide the page's first appearance directly. In 2025 the Largest Contentful Paint (LCP) element was an image on 76% of mobile pages and 85% of desktop pages; 87% of mobile pages also used at least one web font.1 An image loaded the wrong way delays LCP, while an image with no stated size or a font that arrives late shifts the page through Cumulative Layout Shift (CLS). You saw what these metrics mean in the Core Web Vitals lesson; here we look at four questions: which format, which size, which priority, and how to prevent the layout shift.
| Format | When |
|---|---|
| AVIF | Photos; about 50% smaller than JPEG for the same look |
| WebP | Photos and graphics; 25-35% smaller than JPEG on average, and 26% smaller than PNG in lossless mode |
| JPEG | The fallback format for photos |
| PNG | A fallback for images that need transparency or have sharp edges, such as a screenshot |
| SVG | Icons, logos, charts; anything that has to stay crisp at every size |
The source is MDN's format guide.2 WebP works in every modern browser today. AVIF has been supported since Chrome 85, Firefox 93 and Safari 16.1, but MDN still recommends offering a fallback format.2 In the real world the move is slow: in 2025, 57% of LCP images were JPG and 26% PNG, with only 11% WebP; AVIF and the others stayed under 2%.1
The way to offer more than one format is <picture>. The browser skips a <source> whose type it does not support, and falls back to <img> if it supports none of them.3
<picture>
<source srcset="cover.avif" type="image/avif" />
<source srcset="cover.webp" type="image/webp" />
<img src="cover.jpg" width="1200" height="800" alt="Sunset on the beach" />
</picture>Sending a 2000-pixel desktop image to a phone makes the user download bytes they will never see. srcset tells the browser about copies of the same image at different widths, and sizes how much room the image will take on the page; the browser picks the best file for the screen width and the pixel density.4
<img
src="cover-1000.jpg"
srcset="cover-500.jpg 500w, cover-1000.jpg 1000w, cover-1500.jpg 1500w"
sizes="(min-width: 768px) 500px, 100vw"
width="1000"
height="667"
alt="Sunset on the beach"
/>In this example the image is shown 500px wide at 768px and above, and at the screen width below that. A 320px-wide phone with a pixel density of 3 needs 960 pixels, and the browser picks the 1000w file.4 A percentage cannot be used inside sizes; write vw for a relative value.5 If the image is the same size on every screen (an avatar, a logo), 1x and 2x density descriptors are enough.4
Tip
Sending a 3x image to a 3x screen usually goes unnoticed. In a product list, capping the density at 2x reduced the image weight by 45% with no visible loss of quality.6
Always write an image's width and height attributes. The browser works out the aspect ratio from those two values and reserves the space before the image arrives, so the text below it is not pushed down.7 In the cases where you cannot know the size, you can reserve space with the CSS aspect-ratio.7 This is still one of the most common mistakes: in 2025, 62% of mobile pages had at least one image with a missing size.1
loading="lazy" postpones downloading an image until it comes close to the screen; the images further down the page then do not compete for bandwidth with the first visible content. A browser that does not support it ignores the attribute.8
The trap is making an image visible in the first screen lazy too. The browser only works out that the image is on screen after it lays the page out, and the download is delayed.8 In a test on WordPress, taking the first-screen images out of lazy loading improved mobile LCP by 18%, while the number of bytes saved did not change.9 Even so, in 2025 around 17% of mobile pages still lazy-loaded their LCP image.1
Do
Give loading="lazy" to the images below the fold.
Don't
Do not give loading="lazy" to the hero image or the LCP element.8
The browser normally raises the priority of an on-screen image only after it lays the page out. fetchpriority="high" makes the LCP image be requested at high priority from the start, without waiting for that.10 On Google Flights, giving the LCP background image a high priority brought LCP down from 2.6 seconds to 1.9 seconds.10
<img src="hero.avif" fetchpriority="high" width="1200" height="600" alt="Campaign image" />This is a hint, not an order; the browser can still make its own decision.10 In a carousel, give high to the first image only; giving everything a high priority puts nothing in front.11 The "LCP request discovery" insight in Chrome DevTools looks at exactly three things: can the LCP image be found directly in the HTML, does it have fetchpriority=high, and is it not lazy-loaded.12
<Image>next/image is a component built on top of <img>: it produces the srcset for you, picks the format the browser supports by looking at the Accept header, and lazy-loads by default.13
import Image from "next/image";
import hero from "./hero.jpg";
export function Hero() {
return (
<Image
src={hero}
alt="Campaign image"
sizes="100vw"
loading="eager"
/>
);
}The size: width and height are required and only state the aspect ratio; CSS decides the displayed size. For statically imported images (import hero from "./hero.jpg") they are read automatically. When the size is unknown, fill is used, and the parent has to be position: relative.13
sizes: pass it for images made responsive with fill or with CSS. Without it, the browser assumes the image is the screen's width (100vw) and can download a bigger file than needed.13
The LCP image: because the default is lazy, give the LCP image loading="eager" or fetchPriority="high". In Next.js 16 the priority prop is deprecated and preload arrived in its place; the documentation recommends those two options over preload in most cases.13
The format: the default output is WebP. For AVIF, write formats: ["image/avif", "image/webp"] in next.config.13
External sources: images on another domain have to be allowed with remotePatterns. Since Next.js 16 the quality values are also limited by a qualities list, [75] by default.13
One format is enough for a font: WOFF2. It compresses about 30% better than WOFF and has wide browser support.1415 Around 65% of font requests on the web are WOFF2 today.16
Serving a font from your own domain (self-hosting) is faster than downloading it from a third-party server in most cases, because no extra connection is made.15 Around 72% of sites serve at least one font from their own domain.16
preload can be used to get a critical font downloaded early. Because fonts are downloaded with CORS, crossorigin is required; preloading every font, on the other hand, steals bandwidth from the other critical files.15
<link rel="preload" href="/fonts/inter.woff2" as="font" type="font/woff2" crossorigin />What the text does until the font arrives is decided by font-display inside @font-face.1514
| Value | Behaviour |
|---|---|
block | The default. The text is invisible until the font arrives (at most 3 seconds in Chromium and Firefox) |
swap | The text appears immediately in the fallback font and changes when the font arrives; a shift is possible |
fallback | About 100ms of invisibility, then the fallback font; if the font does not arrive within about 3 seconds it is not used |
optional | If the font does not arrive within about 100ms it is not used on that page at all; there is no shift |
swap is the value that shows the text fastest, and it is used on around half of all pages.1416 If you want to prevent layout shift entirely, optional is the safest option, at the cost of the font possibly not appearing on the first visit.714
A subset takes the characters (glyphs) you do not use out of the font, and shrinks the file considerably. If you tell the browser which characters the font covers with unicode-range, the file is only downloaded when one of those characters appears on the page.14 The median font file is around 35 KB compressed; the largest 10% exceed 100 KB, and files that were never subset are among the reasons.16
A variable font carries every weight in a single file instead of separate files for light, regular and bold.14 39% of desktop sites and 41% of mobile sites use at least one variable font.16 The single file can be larger than one static file; if you do not use many weights, the gain is small.14
When the font changes the page shifts, because the web font and the fallback font take up a different width and height for the same text.14 The fix is to make the fallback font resemble the web font: the size-adjust, ascent-override, descent-override and line-gap-override descriptors adjust the fallback font's metrics.7
In Next.js you do not have to do this by hand: next/font works the fallback font out for you.17
next/font downloads the fonts, Google Fonts included, at build time and serves them from your own domain; the browser never makes a request to Google.17 Its defaults are set for performance: display: "swap", preload: true and an automatically computed fallback font to reduce CLS (adjustFontFallback).17
// app/layout.tsx
import { Inter } from "next/font/google";
const inter = Inter({
subsets: ["latin"],
variable: "--font-inter",
});
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={inter.variable}>
<body>{children}</body>
</html>
);
}/* app/globals.css */
@import "tailwindcss";
@theme inline {
--font-sans: var(--font-inter);
}Next.js recommends using a variable font; with a non-variable font, weight is required.17
subsets decides which character set is preloaded; leave it empty while preload is on and you get a warning. Check which subsets your font has on its Google Fonts page.17
For your own font file, next/font/local and src: "./fonts/brand.woff2" are used.17
Tip
If your content has accented or special characters (é, ñ, ø, ł), check from the subset list on the font's Google Fonts page, and with real text, that the subset you picked contains them.17
Full course: the image and font chapters of web.dev's free Learn Performance course.415
Data: the Fonts chapter of Web Almanac 2025; the formats, the hosting, font-display and variable font usage.16
Talk: Paul Calvano's talk on the common performance mistakes in the HTTP Archive data (Lazy Load '22), lazy-loading first-screen images among them.18
Talk: Andrea Verlicchi's talk on automating responsive images (Lazy Load '22).19
Article: Addy Osmani's fetchpriority tip; short examples for the LCP image and for the scripts whose priority should be lowered.20
Sources
The LCP element types and formats, lazy-loaded LCP images, `fetchpriority` and the share of images with no size.
The compression ratios and browser support of AVIF, WebP, JPEG, PNG and SVG, and when to pick which.
Picking a format with `<source type>`, and falling back to `<img>`.
The formats, compression, the `srcset` density and width descriptors, `sizes` and lazy loading.
How the `w` descriptors and `sizes` work together.
A 45% saving from capping images at 2x on high-density phones.
Giving images a size, `aspect-ratio`, why fonts cause shifts, and `size-adjust`.
The `loading` values, the browser support and the warning against making first-screen images lazy.
Felix Arntz and Rick Viscomi. The effect of lazy loading on LCP, with WordPress data and a test.
The `fetchpriority` values, its use on the LCP image and the Google Flights example.
The carousel example, using it together with lazy loading, and the warning to use it sparingly.
The three conditions the DevTools insight checks for the LCP image.
The `next/image` props, `sizes`, `preload`, `priority` being deprecated in Next.js 16, `formats` and `qualities`.
The pros and cons of the `font-display` values, WOFF2, subsets, `unicode-range`, variable fonts and the fallback font.
Preconnect, preload, self-hosting, WOFF2, `font-display` and subsets.
The WOFF2 share, self-hosting, `font-display: swap`, preload and the variable font usage rates.
The `next/font` options, the defaults, subsets, a local font and using it with Tailwind.
Lazy-loaded LCP images, a missing `crossorigin` and unused preloads.
Responsive image practices and an open-source tool that automates them.
Giving the LCP image a high priority and unimportant scripts a low one.
Check the lesson's main ideas with three questions.
Your progress is stored only in this browser.
Last updated: November 3, 2026