Image and font loading for Largest Contentful Paint on a content site
On an article site the LCP element is a heading or a hero image. How to make it discoverable, correctly sized and unblocked by fonts, with Next.js examples.
On a content site Largest Contentful Paint usually fails for dull reasons. A hero image the browser finds late. A font that holds the headline back. An image served at three times the size it is shown. None of this needs a performance specialist, only a look at what the browser does between the first byte and the first meaningful paint, and the removal of the waiting. This walkthrough goes in the order you would work through a template: find the element, split the time, fix the image, fix the font, clear what blocks the paint, then check the result in the right kind of data. The code is Next.js 16, and the reasoning applies to any framework.
Find the element before touching anything#
The LCP element can be an image, a video poster, an element with a CSS background image loaded through url(), or a block-level element containing text. On a content site it is often the article title or the first paragraph, which makes fonts as important as images. web.dev's LCP guidance sets the target at 2.5 seconds or less, at the 75th percentile of page loads, segmented across mobile and desktop.
Do not guess which element it is. Record a performance trace in Chrome DevTools and read the LCP entry, which names the element, or read the diagnostic in a Lighthouse report. Do this per template: an article with a cover image, an article without one, the home page and a topic page often have different LCP elements, which is why one global fix rarely works. Pages share templates, so a fix in the layout reaches hundreds of URLs, and it is worth getting right once.
Split the time into four parts#
The Optimize LCP guide breaks LCP into four sub-parts and gives a rough distribution for a healthy page: about 40 percent time to first byte, under 10 percent resource load delay, about 40 percent resource load duration and under 10 percent element render delay. Its principle is that almost all of the time should go on loading the HTML document and the LCP resource.
That distribution is a diagnostic. A large load delay or render delay means the browser is waiting for something other than bytes, and that is the cheapest thing to fix. A large time to first byte means no image tuning will help; look at caching, server region and rendering strategy instead. A cached or static response typically has a small time to first byte, while a page rendered on every request does not. The sub-part timings come from the DevTools trace, and in the field from the web-vitals library's attribution build, which reports the element and the four timings.
Make the hero image discoverable early#
The browser should find the image in the first HTML it receives. Different ways of delivering the same hero compare like this:
| Approach for the main image | Discoverable early | Risk |
|---|---|---|
Plain img in the server HTML | Yes | The browser may rank it below scripts and styles |
img with fetchpriority="high" | Yes | Overuse dilutes the hint |
link rel="preload" | Yes, even if rendered late | Wrong size or format preloaded, so a double download |
| Background image in CSS | Only after the CSS is parsed | Late discovery, no srcset |
| Image rendered on the client after hydration | No | The request waits for JavaScript |
| Lazy-loaded hero | Delayed | Always adds unnecessary load delay |
So the cover is a real img in server-rendered HTML, with explicit dimensions and a sizes attribute that matches its real layout width, and that one image gets a high fetch priority and is never lazy-loaded. Every image below the fold stays lazy. A carousel whose first slide loads through JavaScript is a late-discovered LCP element in disguise, so render the first slide in the server HTML.
In Next.js 16 the Image component's priority prop is deprecated in favour of preload, and the reference says that in most cases you should use loading="eager" or fetchPriority="high" instead of preload. preload also does not suit pages where several different images could be the LCP element depending on the viewport. For a single cover that is the LCP element on every viewport:
import Image from "next/image";
export function ArticleCover({ src, alt }: { src: string; alt: string }) {
return (
<Image
src={src}
alt={alt}
width={1600}
height={900}
sizes="(max-width: 768px) 100vw, 720px"
fetchPriority="high"
loading="eager"
/>
);
}Each attribute does a job. width and height infer the aspect ratio so the browser reserves space and avoids layout shift; CSS, not these attributes, controls the rendered size. sizes tells the browser how wide the image will be at each viewport width, and without it the browser assumes the image is as wide as the viewport and may download a file far larger than needed. With sizes present, Next.js generates a full srcset.
If the cover is a different element on mobile than on desktop, use fetchPriority="high" on both and leave lazy loading alone, as the reference advises for art-directed pairs; preload or loading="eager" would make both load. Use the hint sparingly. Applied to more than one or two images it stops distinguishing anything.
Send the right bytes#
A 4000 pixel wide photograph shown in a 720 pixel column is the most avoidable cost on a content site. Two settings in next.config matter.
The formats option lists output formats, and Next.js picks one by the request's Accept header, using the first match in the array, so listing AVIF before WebP prefers AVIF where the browser supports it. Each format is cached separately, which increases storage. The qualities allowlist is required starting with Next.js 16: the default is [75], and a requested quality outside the list is coerced to the closest allowed value, with a development warning.
import type { NextConfig } from "next";
const config: NextConfig = {
images: {
formats: ["image/avif", "image/webp"],
qualities: [60, 75],
minimumCacheTTL: 14400,
},
};
export default config;minimumCacheTTL sets the time to live in seconds for optimised images. For local files, the Next.js docs point out that a static import hashes the file's contents and caches the image with an immutable header, so prefer imports where you can. The allowlist exists because unrestricted quality values let anyone request many variants of the same image, each one an extra transformation and an extra cached copy. The cheap options are fewer widths, one preferred format with a fallback, long cache lifetimes and pre-generated images for the handful of covers you publish. Images from a CDN or object storage follow the same logic; serving user images without burning money covers the cost side.
Keep the font off the critical path#
When the LCP element is text, the font is on the critical path. next/font downloads Google Fonts at build time and self-hosts them with your static assets, and the documentation states that the browser sends no requests to Google. That removes a third-party connection from the path.
import { Inter } from "next/font/google";
const inter = Inter({
subsets: ["latin"],
display: "swap",
variable: "--font-sans",
});
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={inter.variable}>
<body>{children}</body>
</html>
);
}Details from the font reference that affect LCP:
displaydefaults toswap, which shows fallback text immediately and swaps when the font arrives.optionalavoids the swap by sometimes never showing the custom font on a first visit.- The
subsetsyou list are preloaded with a link tag in the head, becausepreloaddefaults to true, and omitting subsets while preload is on produces a warning. Do not drop a subset the content needs, such as accented characters for an Italian or French article, or fallback glyphs appear mid-word. adjustFontFallbackdefaults to true for Google fonts and reduces the layout shift of the swap by using a fallback font with matching metrics.- A font called in the root layout is preloaded on every route, one called in a single page only on that route. Call it where it is needed.
Use at most two families, load only the weights the design uses, and do not import a font in a component most pages never render.
Clear what blocks the first paint#
An LCP element can be found early and still paint late if render-blocking work sits ahead of it. Three places to check. Stylesheets that are large or come from another origin: inline the critical CSS or shrink the file. Synchronous scripts in the head, which includes some consent and analytics snippets: load them with async or defer, or after first paint, as the consent article does for the ad script. And client-side rendering of the article body, which delays text that could have been in the server HTML.
Two more things sit above the fold and are easy to forget. A video or social embed there can become the LCP element while you do not control how it loads; replace it with a static preview image that loads the embed on click. And an overly strict content security policy can block an inline preload or a font host, so test the headers from the CSP article against the real page and read the console.
Read the result in the right kind of data#
After a change, measure again at the sub-part level, which tells you why a total moved. If resource load delay dropped, discoverability improved. If load duration dropped, the file got smaller or the connection got better.
Do not expect a lab run and Search Console to agree. A lab run, such as Lighthouse, is one load on one simulated device and network from one location, usually with a cold cache. Field data, from the Chrome User Experience Report (CrUX), is a distribution over real visitors on real devices, networks and cache states, and the number reported is the 75th percentile over a rolling 28-day window. web.dev's account of the differences adds that the field LCP element can vary with screen size, personalisation and shared URLs, and that pages restored from the back/forward cache count in field data as near-instant loads. Two practical consequences follow. Field data decides what to work on and lab data finds the cause, so use the lab trace to explain a bad field number and not to replace it. And a change made today takes weeks to fully show in a 28-day window, so confirm it the same day in the lab and wait for the field to confirm it later.
One metric needs a different tool. Interaction to Next Paint (INP) depends on real interactions, and a plain page-load run has none to observe. Total Blocking Time is the usual lab stand-in, which web.dev calls a reasonable proxy and not a substitute. Lighthouse's INP audit supports only timespan mode, which runs over a period of interaction in a user flow, so a navigation-mode report will not contain it. If you are reading an INP number from Lighthouse, confirm the mode before trusting it.
If your pages already pass at the 75th percentile in field data, leave them alone: tuning a passing metric costs time and risks regressions. If the LCP element is plain text in system fonts, the work is in server response time and not in images or fonts. And on a hosted platform where you do not control the template, the lever is the images you upload: correct dimensions and a sensible file size before they reach the platform.
Related articles
All articles →A nonce gives a strict script policy but ends static rendering; a static header keeps pages cached but needs unsafe-inline. How to choose on a Next.js 16 site.
11 min
Derive a width sweep from your own CSS breakpoints, assert no horizontal scroll and 24 px targets in Playwright, and keep screenshots to a reviewed handful.
11 min
Design for a site in eight languages with one maintainer: next-intl routing, ICU plurals, CI checks for broken messages, stale-translation tracking, hreflang.
13 min