Blog / Technical SEO /

Lazy loading images: when it helps and when it hurts LCP

Here’s a pattern I’ve seen more than once. Someone installs a speed plugin, ticks “lazy load all images”, runs PageSpeed Insights, and the score goes down. The big red warning now says something like “Largest Contentful Paint image was lazily loaded”.

They did the thing every speed guide told them to do. So what happened?

Lazy loading is brilliant for images further down the page. It’s actively harmful for the one image that matters most: the big one at the top. The trick is knowing which is which.

The short answer

  • Lazy load images below the fold: the ones a visitor only sees after scrolling.
  • Don’t lazy load the image that’s visible the moment the page opens, especially if it’s your Largest Contentful Paint (LCP) element.
  • Most sites only need to exclude one or two images per template. That’s it.

What lazy loading actually does

Without lazy loading, the browser downloads every image on the page as soon as it finds it in the HTML. A long blog post with twenty images downloads all twenty, even if the reader leaves after the first paragraph.

With lazy loading, the browser waits. It only fetches an image when it’s about to scroll into view. Less data, fewer requests competing with each other early on, and a faster first view for most pages.

These days you don’t need JavaScript for it. Modern browsers support it natively:

<img src="team-photo.jpg" alt="The team at the launch event" loading="lazy" width="800" height="533">

WordPress has added loading="lazy" to images automatically since version 5.5, and later versions try to skip the first content image. Many themes and plugins add their own lazy loading on top, which is where things get messy.

Why it hurts LCP

LCP measures how long it takes for the largest thing in the viewport (usually a hero image, a featured image or a big heading) to appear. Google’s “good” threshold is 2.5 seconds or less.

When that largest element is a lazy-loaded image, the browser does this:

  1. Downloads the HTML.
  2. Downloads and processes the CSS so it can work out the layout.
  3. Only then realises the image is in the viewport.
  4. Starts downloading the image.

A normal image would have started downloading at step 1, as soon as the browser spotted it in the HTML. Lazy loading pushes the most important image to the back of the queue. On a fast connection you may not notice. On a mid-range phone on a patchy mobile network, which is a lot of real visitors, you’ll notice.

JavaScript lazy loading is worse still, because the script itself has to load and run before it even starts looking for images.

When lazy loading helps

  • Long articles with several images in the body.
  • Category and archive pages with rows of thumbnails.
  • Product grids, where only the first row or two is visible on load.
  • Image galleries, carousels (everything except the first slide) and footers with logos.
  • Embedded videos and maps, which are heavy. Iframes support loading="lazy" too.

If a visitor has to scroll to see it, lazy load it.

When it hurts

  • Hero images and full-width banners at the top of the page.
  • Featured images that sit above the post title or right below it.
  • The logo, if it’s an image. It’s small, but it’s always visible.
  • The first product image on a product page.
  • Anything above the fold on mobile. Check mobile specifically, because what’s above the fold on a phone is often different from desktop.

How to find your LCP element

Don’t guess. It’s often not the image you’d expect.

  1. Open PageSpeed Insights and test the page.
  2. Scroll to the diagnostics and find “Largest Contentful Paint element”. It shows you exactly which element it is.
  3. If you see the warning “Largest Contentful Paint image was lazily loaded”, you’ve found your problem.

You can also use Chrome DevTools: open the Performance panel, record a page load, and look for the LCP marker in the timings.

Test a few templates, not just the home page: a blog post, a category page, a product page if you have one. Each template usually has a different LCP element.

How to fix it

Remove lazy loading from that image

If you control the HTML, remove loading="lazy" from the hero image, or set it to loading="eager".

On WordPress, most speed and image plugins let you exclude images, either by class name, by file name, or with an option like “skip the first X images”. Use it. If your theme lazy loads with its own script, check its settings too, so you’re not fighting two systems.

Tell the browser it matters

The fetchpriority="high" attribute tells supporting browsers to fetch an image early:

<img src="hero.jpg" alt="..." fetchpriority="high" width="1600" height="900">

Use it on one image per page, the LCP image. If everything is high priority, nothing is.

If the hero is a CSS background image, the browser can’t discover it until the CSS loads. A <link rel="preload" as="image"> in the head helps there, though switching to a normal <img> tag is usually the cleaner fix.

Keep the width and height

Whatever you do, keep width and height on every image, lazy or not. They let the browser reserve the space before the image arrives, which keeps Cumulative Layout Shift (CLS) down. Lazy-loaded images without dimensions are a classic cause of content jumping around as you scroll.

Make the image smaller

Not lazy loading the hero means it loads early. It still has to load. A 2 MB hero image is slow whether it’s first in the queue or last. Resize it to the size it’s actually shown at, compress it, and use a modern format like WebP where you can.

A quick checklist

  1. Test your main templates in PageSpeed Insights and note the LCP element for each.
  2. Make sure none of those LCP images are lazy loaded.
  3. Add fetchpriority="high" to the LCP image if your setup allows it.
  4. Keep lazy loading on for everything below the fold.
  5. Check width and height are set on all images.
  6. Re-test on mobile, not just desktop.

What about FID and CLS?

Lazy loading has little to do with First Input Delay, which is mostly about JavaScript keeping the browser busy. (Google has also said Interaction to Next Paint will replace FID as a Core Web Vital in March 2024, so it’s worth keeping an eye on that one.) The CLS connection is the width-and-height point above. Get the dimensions right and lazy loading won’t hurt your CLS.

Open PageSpeed Insights, test your most important page, and look for that one warning. If it’s there, it’s probably the quickest LCP fix you’ll make all year.