Largest Contentful Paint (LCP) Explained and How to Fix It
Largest Contentful Paint measures when the biggest visible element renders. What counts, the four phases of LCP, and practical ways to make it faster.
Largest Contentful Paint (LCP) is the time from when a user starts loading a page until the largest image or text block in the viewport finishes rendering. It is the Core Web Vital that answers “when did the main content show up?” A good LCP is 2.5 seconds or less at the 75th percentile of real page loads. Fixing it usually means getting one specific element, often a hero image, discovered and downloaded sooner.
What counts as the largest contentful element
The browser tracks candidate elements as the page renders and reports the largest one visible in the viewport. Eligible elements include:
<img>elements, including the first frame of an animated image<image>elements inside an SVG- The poster image of a
<video>, or its first painted frame - Elements with a CSS
background-imageloaded viaurl() - Block-level elements containing text
Size means the visible area within the viewport, not the intrinsic size of the file. An image scaled down to a small thumbnail counts at its displayed size, and parts clipped off-screen do not count. The candidate can change as the page loads: a heading might be the largest element at first, then a hero image takes over once it paints. Measurement stops at the first user interaction, such as a tap, click, or key press.
Some elements are deliberately ignored, such as fully transparent elements and images that are treated as low-content placeholders. In practice, on most marketing pages, articles, and product pages, the LCP element is either a hero image or the main headline.
The four phases of LCP
LCP is easier to fix when you split it into parts. For an image-based LCP element, the total time breaks down into:
- Time to first byte. How long until the HTML starts arriving. Slow servers, redirects, and missing CDN caching all show up here. See our explainer on time to first byte.
- Resource load delay. The gap between the first byte and when the browser starts fetching the LCP image. This is where discovery problems live.
- Resource load duration. How long the image itself takes to download.
- Element render delay. The time between the image finishing and it actually appearing on screen, often caused by render-blocking CSS or JavaScript.
For text-based LCP, phases two and three disappear unless a web font is involved, and the focus shifts to server response and render-blocking resources.
A useful rule of thumb: most of the time should be spent in the first and third phases. Large load delay or render delay means the browser was waiting on something other than the network work it actually needed to do.
Fixing resource load delay
This is the most common problem and often the easiest to fix. The browser’s preload scanner finds images by reading the HTML. If the LCP image is not in the HTML, the browser cannot start fetching it early.
Typical causes:
- Images injected by JavaScript. A client-rendered hero waits for the bundle to download, parse, and run before the image request even begins. Server-render the markup instead.
- CSS background images. The browser does not know about them until the stylesheet is downloaded and the matching element is styled. Use a real
<img>for the hero, or preload it. - Lazy loading the hero.
loading="lazy"on an above-the-fold image delays it on purpose. Lazy loading is for images below the fold; our guide to lazy-loading images covers where the line belongs.
Two attributes help directly. fetchpriority="high" on the LCP image tells the browser to prioritize it over other images it discovers at the same time, as explained in the fetchpriority guide. A <link rel="preload"> lets you announce an image the HTML would otherwise reveal late, which is covered in preload, prefetch, and preconnect. If the image lives on another origin, a preconnect to that origin saves the connection setup.
Fixing resource load duration
Once the request starts, make the bytes smaller and closer:
- Serve modern formats where supported. Our comparison of WebP, AVIF, and JPEG explains the trade-offs.
- Serve the right size for the viewport with
srcsetandsizes, so phones do not download desktop images. See responsive images with srcset and sizes. - Put images behind a CDN with long cache lifetimes.
- Avoid competing for bandwidth: dozens of other high-priority requests early in the load will slow the one that matters.
Fixing element render delay
If the image has arrived but is not on screen, something is blocking rendering. Large stylesheets in the <head>, synchronous scripts, and client-side frameworks that hide content until hydration are the usual suspects. Inline the critical CSS for above-the-fold content, defer non-essential scripts, and make sure the server-rendered HTML is visible without waiting for JavaScript. The critical rendering path explains what the browser must finish before the first paint.
Web fonts can delay text-based LCP. A font-display value that shows fallback text immediately prevents invisible headlines while the font downloads.
Measuring LCP correctly
There are two kinds of data:
- Field data comes from real users and is what counts for the Core Web Vitals assessment. It reflects real devices, networks, and cache states.
- Lab data comes from a controlled run in developer tools. It is reproducible and great for debugging, but it represents one device on one network.
In the browser, you can observe LCP candidates with a PerformanceObserver:
new PerformanceObserver((list) => {
const entries = list.getEntries();
const last = entries[entries.length - 1];
console.log("LCP:", last.startTime, last.element);
}).observe({ type: "largest-contentful-paint", buffered: true });
The last entry before the user interacts is the final LCP. Logging the element tells you exactly which node to optimize, which is the first question to answer before changing anything.
How LCP relates to the other vitals
LCP measures loading. Cumulative Layout Shift measures visual stability, and Interaction to Next Paint measures responsiveness. They interact: an image without width and height attributes might load quickly but shift the layout when it appears, and heavy JavaScript that delays rendering often hurts responsiveness too. For the broader picture, see the Core Web Vitals guide.
The takeaway
LCP is the moment the biggest visible element finishes rendering, and a good score is 2.5 seconds or less. Identify the LCP element first, then split its time into server response, load delay, load duration, and render delay. Most wins come from making the hero discoverable in the HTML, giving it high fetch priority, never lazy-loading it, and serving a properly sized, modern image format.
Keep reading
Takina · · 5 min read Cache Busting Explained: Hashed Filenames and Long Caching
Cache busting puts a content hash in asset filenames so browsers can cache files for a year yet still fetch new versions the moment you deploy.
Takina · · 4 min read What Is Minification? Shrinking JavaScript, CSS, and HTML
Minification strips whitespace, comments, and long names from JavaScript, CSS, and HTML without changing behavior. How it works and pairs with compression.
Takina · · 5 min read Cumulative Layout Shift (CLS) Explained and How to Fix It
Cumulative Layout Shift measures how much visible content unexpectedly moves while a page loads. How CLS is scored, what causes it, and how to fix it.