Lazy loading is a simple technique: the browser downloads an image only when it's about to come into view, instead of downloading every image on the page right away. On a collection with 48 products, that means loading the few photos you can see at first and the rest as you scroll.

You no longer need JavaScript libraries to do it: a single HTML attribute is enough. But used the wrong way, it slows down exactly the part of the page that matters most.

How it works today

The standard way is the loading attribute on the image tag:

<img src="foto-prodotto.jpg" loading="lazy" width="800" height="1000" alt="Sneakers in pelle bianca viste di lato">

There are two values:

  • lazy: the browser defers the download until the image gets close to the viewport;
  • eager: the default behavior, the image downloads right away wherever it is.

As web.dev's guide to native lazy loading explains, the attribute is supported by Chrome, Edge, Firefox and Safari; browsers that don't recognize it ignore it and load the image normally. The browser doesn't wait for the image to be visible: it downloads it a bit earlier, at a distance it decides based on the connection type. The same attribute also works on iframe elements, such as embedded YouTube videos or maps.

Native lazy loading applies to images and iframes. It doesn't apply to background images set in CSS, nor to CSS and JavaScript files, which are optimized in other ways.

When it helps and when it hurts

It helps on any long page with lots of images: collections, blog posts, homepages with many sections, galleries. People who don't scroll all the way down don't download photos they'll never see, and the initial page is lighter, especially on a phone with a slow connection.

It hurts when you apply it to images that are visible right away. web.dev's rule is clear: don't lazy load images that are visible when the page opens, especially the one that serves as the Largest Contentful Paint (LCP), meaning the largest element on the first screen. It's usually the main homepage photo or the first product photo. If it's lazy loaded, the browser waits before downloading it and the page feels slower.

For that image, do the opposite: leave it without loading="lazy" and, if you want to give it priority, add fetchpriority="high".

Always set width and height

With lazy loading, images arrive as you scroll. If the tag is missing width and height, the browser doesn't know how much space to reserve and the text jumps down when the image appears. It's the problem Google measures as Cumulative Layout Shift. Dimensions in the tag (or a fixed aspect ratio in CSS) prevent it.

Lazy loading on Shopify

In recent Shopify themes, images are generated with the Liquid filter image_tag, which already does a lot on its own:

  • it adds width and height taken from the image;
  • it creates the srcset, meaning several sizes of the same photo, so phones download a smaller version;
  • it automatically sets loading="lazy" for images in sections lower down the page, and not for those at the top.

If your theme uses image_tag, you usually don't need to do anything. Check two cases:

  • The theme is old or customized and writes <img> tags by hand: make sure images below the first screen have loading="lazy" and that all of them have width and height.
  • The first section isn't the first one people see, for example because there's an announcement bar or an unusual header. In this case the automatic logic can get it wrong. Shopify's documentation notes that you can write your own rule with the section.index and section.location properties.

Apps

Many optimization apps promise to "turn on lazy loading." With a modern theme it's often work that's already done, plus one more script to load. Before installing one, check what your theme already does.

Lazy loading and Google

Google sees lazy-loaded images, as long as they load when they come into view and not after a user action. From the Google Search Central guide:

  • the native loading attribute and the IntersectionObserver API are fine;
  • don't make loading depend on a scroll or a click: Google doesn't interact with the page;
  • for infinite scroll, each block of products must also have its own URL, with linked pagination.

To check, use the URL Inspection tool in Search Console and, with View crawled page, make sure the image URLs appear in the src attribute in the HTML.

How to check your site

  1. Open the page in Chrome, then the developer tools, Network tab, Img filter.
  2. Reload without scrolling: only the images on the first screen should download.
  3. Scroll: the others should arrive as you go.
  4. Inspect the main image at the top: it must not have loading="lazy".
  5. Run PageSpeed Insights on the page: it flags whether the LCP image is lazy loaded.

Finally, remember that lazy loading decides when to download an image, not how heavy it is. Formats, dimensions and compression are still the first job: you'll find them in the guide to image optimization on Shopify. If you want a speed check of your store, let's talk.