Skip to content

Slow LCP: make your hero image load first

Guide/ 12 min read

Three fixes for a hero image that shows up late: drop lazy loading, set fetchpriority and serve the right size, measured in a local demo.

  • Performance
  • Core Web Vitals
  • Liquid
In this article (8)
  1. What LCP is and the threshold to hit
  2. Fix 1: no loading="lazy" on the hero image
  3. Fix 2: fetchpriority="high"
  4. Fix 3: the right size and format
  5. How to measure LCP before and after
  6. Common mistakes
  7. Frequently asked questions
  8. Checklist

LCP (Largest Contentful Paint) measures how long the largest element on screen takes to render, and on a store that is usually the hero image. Google counts 2.5 seconds or less as good. If your hero shows up late, the cause is usually one of three things: lazy loading, low priority or a file that is too big.

This post walks through the three fixes with HTML and Shopify Liquid code, how to measure before and after, and the numbers from a local demo where we applied them one at a time. For the bigger picture of why stores get slow, start with store speed is usually an architecture problem.

What LCP is and the threshold to hit

LCP marks the moment the largest image or text block visible on screen gets painted, counted from when the user starts loading the page. Per web.dev's LCP guide, the candidates are <img> elements, <image> inside an SVG, a <video> poster or first frame, CSS backgrounds loaded with url() and blocks of text. On a home or product page, the big photo at the top nearly always wins.

LCPRating
2.5 s or lessGood
Between 2.5 and 4 sNeeds improvement
Over 4 sPoor

The threshold applies to the 75th percentile of real visits, with mobile and desktop counted separately. In practice: a fast load on your laptop is not enough; three visits out of four have to come in at 2.5 s or less.

LCP thresholds, per web.devgoodneeds improvementpoor0 s2.5 s4 sslowerhow the verdict is reachedmeasured on real visits (field data, CrUX)mobile and desktop are assessed separately75% of visits have to land in "good"good = 2.5 s or lessif more than one visit in four goes past 2.5 s, it is no longer "good"

Scroll the figure sideways to see all of it

To know what to fix, web.dev's guide to optimizing LCP splits it into four subparts: time to first byte (TTFB), resource load delay (from that first byte until the browser starts fetching the image), resource load duration (how long the image takes to download) and element render delay (from arrival to paint). Fixes 1 and 2 cut the load delay; fix 3 cuts the load duration.

Fix 1: no loading="lazy" on the hero image

loading="lazy" tells the browser not to request the image until layout confirms it is on screen. For photos further down, that is exactly right. For the hero, it is a brake: web.dev puts it bluntly, never lazy-load your LCP image, because it always adds resource load delay.

This is not a corner case. In a 2022 study, web.dev found that sites using lazy loading had worse LCP: a median 75th-percentile LCP of 3,546 ms with lazy loading against 2,922 ms without. That is a correlation, but their WordPress A/B test did measure the effect: removing lazy loading from above-the-fold images cut LCP by about 13% on desktop and 15% on mobile on archive pages (the performance effects of too much lazy loading).

The mistake looks like this:

<img src="/img/hero-2400.jpg" loading="lazy" alt="Blue ceramic mug on a wooden table">
sketch: the same page, two ways to request the herobefore · loading="lazy", 2400 px JPEGHTMLproductshero imageLCPafter · fetchpriority="high", 800 px WebPHTMLhero imageproductsLCP0timethe hero image goes out in the first batchsame HTML: what changes is when the download starts and its size

Scroll the figure sideways to see all of it

Shopify adds two more traps. First, unless you say otherwise, the image_tag filter sets loading="lazy" on images in sections further down the page. Fine, unless your hero section is not the first one. Second, JavaScript lazy-loading libraries such as lazysizes swap src for data-src, so the browser cannot see the URL until the script runs. Shopify calls lazy-loading the LCP image one of the most common and damaging anti-patterns in themes, in its guide Never lazy-load the LCP image. This is the pattern it suggests for a banner section:

{%- liquid
  assign hero_loading = 'eager'
  assign hero_priority = 'auto'
  if section.index == 1
    assign hero_priority = 'high'
  elsif section.index > 3
    assign hero_loading = 'lazy'
  endif
-%}
<div class="hero-banner">
  {%- if section.settings.image != blank -%}
    {{ section.settings.image
      | image_url: width: 1600
      | image_tag:
          loading: hero_loading,
          fetchpriority: hero_priority,
          widths: '600, 900, 1200, 1600',
          sizes: '100vw'
    }}
  {%- endif -%}
</div>
  • assign hero_loading = 'eager': by default the image loads right away. eager is the browser's normal behavior; leaving the attribute out does the same.
  • if section.index == 1: when the banner is the page's first section, it is the LCP candidate and gets the higher priority (fix 2).
  • elsif section.index > 3: from the fourth section on, it does lazy-load. The test is positive on purpose: section.index is nil in the theme editor, in static sections and in the Section Rendering API, and a condition like section.index <= 3 would send the image to lazy in exactly those cases.
  • image_url: width: 1600: the largest width you request from Shopify's CDN.
  • widths and sizes: they build the srcset and tell the browser how wide the image renders (fix 3).

Dawn, Shopify's reference theme, does the same in its banner: fetchpriority set to high when section.index == 1.

Fix 2: fetchpriority="high"

Left alone, the browser starts every image at low priority and only bumps up the ones on screen once layout is done. That wait is load delay. Per web.dev's Fetch Priority guide, fetchpriority="high" on the LCP image skips it; in a Google Flights test, LCP went from 2.6 s to 1.9 s. It works in Chrome and Edge 102, Firefox 132 and Safari 17.2.

Two caveats. It is a hint, not a directive: the browser weighs it against its own heuristics. And it only works if you use it sparingly: web.dev says setting high priority on more than one or two images stops it from helping, and Shopify asks for one per page, never together with loading="lazy" (Mark the LCP image with fetchpriority="high"). On a product page, where the main photo sits in the first section, it looks like this:

<div class="product-media">
  {{ product.featured_image
    | image_url: width: 1200
    | image_tag:
        loading: 'eager',
        fetchpriority: 'high',
        widths: '400, 600, 800, 1000, 1200',
        sizes: '(min-width: 990px) 50vw, 100vw'
  }}
</div>
  • product.featured_image: the product's featured image.
  • loading: 'eager' and fetchpriority: 'high': image_tag passes any parameter named after an HTML attribute straight to the <img> tag.
  • sizes: '(min-width: 990px) 50vw, 100vw': on screens 990 px and wider the photo takes half the viewport; on a phone, the full width. Match it to your real layout.

If your hero is a CSS background (background-image), the browser does not find it while parsing the HTML. For that case web.dev recommends a <link rel="preload" as="image"> with fetchpriority="high"; on Shopify, image_tag has a preload: true parameter that sends the hint as a Link header. Keep it for the top image only.

Fix 3: the right size and format

Even when the image is requested on time, a 1.4 MB file takes a while on a phone with a weak connection. That is the load duration, and you cut it by serving a file as wide as it renders, in a modern format: web.dev names AVIF and WebP. In HTML that means srcset with several widths and sizes with the on-screen width:

<img
  src="/img/hero-800.webp"
  srcset="/img/hero-480.webp 480w, /img/hero-800.webp 800w, /img/hero-1200.webp 1200w"
  sizes="100vw"
  width="1200"
  height="675"
  fetchpriority="high"
  alt="Blue ceramic mug on a wooden table">
  1. src: the default file, for browsers that do not understand srcset.
  2. srcset: three files with their real pixel widths (480w, 800w, 1200w). The browser picks one.
  3. sizes="100vw": the image spans the full viewport. From that and the screen density, the browser works out which file it needs. A 412 px phone at 1.75 density needs about 721 px and takes the 800 one.
  4. width and height: the image's aspect ratio. They do not speed up LCP, but they reserve the space before the file arrives so the page does not jump (CLS).
  5. fetchpriority="high": fix 2, and with no loading="lazy", fix 1.

On Shopify you do not have to make the files. The image_url filter resizes on the CDN (up to 5760 px) and Shopify picks the format based on what each browser supports, so you upload a good original and pass widths and sizes to image_tag, as in both Liquid examples above. image_tag also adds width and height for you.

the 3 fixes and which part of LCP they cut#fixin the codelcp subpart1no lazydrop loading="lazy"load delaythe browser requests it while parsing HTML2high priorityfetchpriority="high"load delayno waiting for layout to get bumped up3size and formatsrcset + sizes, WebPload durationa phone downloads the file for its width+ width and height on the img: reserve the space, no layout jumps (CLS)two cut the wait; one cuts the download1 is one of the most common theme mistakes, per Shopify's docs

Scroll the figure sideways to see all of it

How to measure LCP before and after

There are two kinds of data. Field data comes from real visits: the Core Web Vitals report in Search Console, the Chrome UX Report (CrUX) and the top part of PageSpeed Insights; that is what the threshold is judged on. Lab data comes from one controlled load: Lighthouse, the Chrome DevTools Performance panel or WebPageTest. It is good for comparing one change against another, but it is not your real LCP.

To see which element is your LCP, paste this into the DevTools console and reload:

new PerformanceObserver((list) => {
  const entries = list.getEntries();
  const last = entries[entries.length - 1];
  console.log("LCP", Math.round(last.startTime), "ms", last.element);
}).observe({ type: "largest-contentful-paint", buffered: true });
  • PerformanceObserver: listens to the performance entries the browser records.
  • entries[entries.length - 1]: the browser can report several candidates while the page loads; the last one is the LCP so far.
  • last.element: the DOM node. Hover it in the console to highlight it on the page.
  • buffered: true: includes entries recorded before you pasted the code.

On our demo with loading="lazy", it logged two lines: a product photo first, then the hero. With lazy loading, a small photo got painted before the big one.

To compare versions, we built a minimal store page in four variants, identical except for the hero, and served it on 127.0.0.1 with Node. The images are synthetic (made with sharp). Each variant was measured three times with Lighthouse 13.5.0 using this command (shown for the English copy of the first page):

lighthouse http://127.0.0.1:4173/en-0-before.html --only-categories=performance --throttling-method=devtools --chrome-flags="--headless=new" --output=json --output-path=before.json
  • --only-categories=performance: the performance audit only.
  • --throttling-method=devtools: actually throttles network and CPU during the load (150 ms latency, about 1.5 Mbps down, 4x slower CPU), on Lighthouse's default mobile emulation.
  • --output=json: saves the report so you can read the LCP (largest-contentful-paint) and its breakdown.
VariantHero imageLCP (median of 3)
Before2400 px JPEG, 1,410 KB, loading="lazy"10.8 s
Fix 1Same JPEG, no loading="lazy"10.3 s
Fixes 1 + 2Plus fetchpriority="high"10.3 s
Fixes 1 + 2 + 3800 px WebP, 89 KB, with srcset and sizes2.9 s

This is a local lab measurement, not field data, and it reads honestly. Dropping lazy loading moved the image request from 1.27 s to 0.62 s and cut LCP by half a second. fetchpriority made no measurable difference here: the page has a single heavy image and few competing requests, and web.dev notes that prioritization matters more when many resources fight for bandwidth (our server was also HTTP/1.1). File weight is what moved LCP the most. With Lighthouse's default simulated throttling, the first three variants all came out at 9.6 s: it did not pick up the lazy-loading delay on this page, which is why we used devtools.

On your store, the DevTools Performance panel shows the LCP breakdown under Insights, and the Priority column in the Network panel tells you whether the image went out at high priority. Measure before you touch anything and after each change, in mobile emulation.

Common mistakes

  • Lazy-loading the hero. Through a theme setting, a speed app or a JavaScript library. Check the HTML that arrives, not the section's code.
  • Using section.index <= 3 to decide. In the theme editor section.index is nil and the comparison fails. Test section.index > 3 for the lazy case.
  • Putting fetchpriority="high" on every image. If everything is urgent, nothing is. One per page.
  • Combining fetchpriority="high" with loading="lazy". They contradict each other. Shopify says never to do it.
  • srcset without sizes. Without sizes, the browser assumes the image spans the full viewport and may download a larger file than you display.
  • A hero set as a CSS background. The browser finds it late. Move it to an <img> or preload it.
  • Measuring only on your laptop. The threshold is the 75th percentile of real visits, with mobile on its own.

Frequently asked questions

Is loading="eager" better than leaving the attribute out?

They are the same: eager is the browser's default. Writing it out, as Shopify's examples do, makes the intent clear and stops someone from flipping it to lazy without thinking.

Can I put fetchpriority="high" on several images?

You can, but it stops working. web.dev says high priority on more than one or two images no longer helps LCP, and Shopify recommends exactly one per page: the LCP image.

What if my page's LCP element is text?

Then these fixes do not apply to that element. Look at the breakdown: if the time goes into the first byte, the problem is the server; if it goes into rendering, look at what blocks the paint, such as stylesheets or fonts.

Why does PageSpeed Insights show a different number from Lighthouse?

Because it mixes two sources: field data from real visits at the top and a lab test below it. On top of that, every lab run uses a different network and machine. Always compare with the same tool and settings.

Checklist

  • You know which element is the LCP on your home page and your product page.
  • The hero image has no loading="lazy" and no data-src.
  • It has fetchpriority="high", and no other image on the page does.
  • On Shopify, the loading logic tests section.index > 3 for lazy.
  • It has srcset, a real sizes, width and height.
  • The file a phone downloads matches its rendered width and is WebP or AVIF.
  • You measured before and after with the same tool, in mobile emulation.
  • You check the Core Web Vitals report in Search Console a few weeks later.

A fast hero is the first impression; next, make sure the rest of the purchase does not stall. Check mobile checkout autocomplete and the right keyboard and, so your products look right in Google, product structured data. If your add-to-cart button lags too, continue with the slow button and INP.

Saw this on Instagram? Comment LCP on the Reel and I'll send you the guide.

Written by

Luis Morales

Luis Morales

Frontend and Shopify developer, EcomLabs

@luismoralesdev on Instagram

Published October 30, 2026 · updated November 1, 2026

← Blog