Mark the LCP image with fetchpriority="high"
Apply fetchpriority="high" to the LCP image to signal its importance to the browser and allow it to be downloaded sooner than other images.
By default, all images are discovered with a Low priority. After the initial HTML is parsed and layout is complete, the browser discovers which images are in the viewport and upgrades their priority to High. This creates a delay between when the browser could start downloading a critical image and when it actually does. Using fetchpriority="high" eliminates that delay for the LCP image.
Use fetchpriority="high" on the LCP image only, one per page. Combine it with loading="eager" or no loading attribute. Never use it with loading="lazy". Requirements:
- You must be certain it's the LCP element.
- It must be visible in the initial viewport.
- It should be the hero image or the main product image.
- The first section is preferred (
section.index== 1).section.indexisnilin the theme editor, in static sections, and in Section Rendering API responses, so write the lazy branch as a positivesection.index > Ntest and letnilfall through to the eager branch. See Usesection.indexfor position-aware loading.
Overusing fetchpriority="high" can degrade performance by interfering with the browser's own prioritization heuristics. Use it only when you have specific knowledge about an element's importance that the browser doesn't have yet.
Overusing fetchpriority="high" can degrade performance by interfering with the browser's own prioritization heuristics. Use it only when you have specific knowledge about an element's importance that the browser doesn't have yet.
Anchor to ExamplesExamples
Complete pattern for handling image loading based on section position:
Anchor to TestingTesting
- Use Performance > Insights to identify the LCP element and its resource load delay.
- Check the Network panel waterfall to see when the LCP image starts downloading. Enable the Priority column to verify the priority is High.
- Compare with and without the attribute to measure improvement.
Anchor to ReferencesReferences
image_tagfilter withfetchpriorityparameterimage_urlfilterproduct.featured_imagesection.indexif/elsiftags- The
fetchpriorityattribute in the HTML Standard fetchPriorityon MDN- Never lazy-load the LCP image
- Prevent image layout shift
- Use
section.indexfor position-aware loading