Largest Contentful Paint is the moment the biggest element in the first screen becomes visible. Google's target is 2.5 seconds or less. To fix it, first find out which element it is. A speed test report shows its HTML.
The four parts of LCP
- Time to first byte: how long the server takes to start sending the page.
- Resource load delay: how long the browser waits before it starts downloading the LCP image.
- Resource load duration: how long the download takes.
- Element render delay: the time between the download and the element appearing.
If the server is slow
Add page caching and a CDN. A first byte later than about 0.8 seconds makes a good LCP hard to reach.
If the image starts loading late
The image has to be in the HTML, not inserted by JavaScript or set as a CSS background. Do not lazy-load it, and tell the browser it is important:
<img src="/hero.avif" width="1200" height="600"
fetchpriority="high" alt="Product photo">If the download is slow
Serve the image at the size it is displayed, in a modern format such as AVIF or WebP. A 2400 pixel wide photo shown at 800 pixels wastes most of its bytes.
If the element renders late
Render-blocking stylesheets and scripts in the head delay everything. Defer scripts that are not needed for the first screen and keep the CSS small.