Updated: May 16, 2019

What is Lazy Loading?

Lazy Loading is a performance optimization technique that loads images as the user scrolls down the page, instead of during the initial page load.

Also known as “defer offscreen images“.

We often see a 10% – 30% reduction in page weight by implementing lazy loading.

On the browser side, the page loads faster because it’s not loading all the images right away.

On the tech side, it works by replacing the html image src attribute with a data-src placeholder – this prevents the image from loading in the standard html sequence. Then javascript is used to grab that placeholder url and update the element’s src attribute, loading the image when it comes into view.

The Google effect: Lazy loaded images don’t contribute to the initial page load, so your site is lighter and gets the benefits that come with a faster load time (improved rankings and traffic).

Why is Lazy Loading Awesome?

  1. The page loads faster!
  2. Faster pages = better SEO rankings
  3. Faster pages = better conversion rates

Consider this:

mobile speed affects conversion rate

Now let’s take a look at this example of a customer’s home page before and after implementing lazy loading:


shopify page before lazy loading

Pretty heavy page with a slow load time at this point, buuuuuut…


shopify page after lazy loading

Check the highlights after this one optimization:

  • Mobile load time improved by over 2.5 seconds
  • 20 fewer server requests
  • Page weight decreased by 1MB
  • Nice!

Those stats are using webpagetest.org with mobile LTE 12Mbs download speed.

If you’re on the edge of your seat waiting to hear how this story ends, I’ll share… we did more optimization work on their site, and here’s a snapshot of their performance today:


Major weight reduction helped make significant speed improvements.

Most sites with a lot of edits and installed/uninstalled apps benefit from our full service packages, but every site benefits from lazy loading.

… unless you already have lazy loading, in that case good job 👍

How to Add Lazy Loading to Your Shopify Theme

Option A) If you like saving time and want it done for you, we have a Shopify lazy loading service here.

We can usually lazy load videos as well (if they’re not at the top of the page).

Option B) If enjoy working with code and want to take a crack at it, you can use a library like lazysizes to implement on your site.

The instructions to implement using lazysizes are on that page if you scroll down.

The exact files to edit in your Shopify site will vary based on your theme, but generally you want to look for the template code that loads images, and swap in the lazy loading syntax explained by lazysizes (or whatever library you end up choosing).

For example, if you’re using the lazysizes library, once you have that installed in your theme.liquid file, you want to swap out your standard img tags:

<img src="IMAGE_URL">

With the new lazy loading syntax:

<img data-src="IMAGE_URL" class="lazyload">

To install the library, download the latest file from that lazysizes page, upload to your Shopify theme Assets folder and name it lazysizes.min.js, then include it in your theme.liquid <head> section like this:

<!--Lazy Loading -->
{{ "lazysizes.min.js" | asset_url | script_tag }}

*The <style> part is used to create a subtle CSS animated fade in effect.

Once you have the code setup, you’ll see your images fade into view as you scroll down your site, rather than all at the initial page load (you can also refresh this page and scroll down really fast to try and catch the affect here).

To see if you have lazy loading on your site, you can run it through the Shopify Analyzer.

A second way to check is by inspecting the browser code by right clicking on your page, then selecting “View source”. Search for “lazy” on that page – if there aren’t any elements with “lazy” then you probably don’t have it.

If you view source and see some “lazy” elements, it’s still worth running through an analyzer tool to make sure they’re all loaded with “true lazy loading” (and not just “placeholder lazy loading”).

Lazy loading can usually speed up your Home page, Collection pages, Product pages, and Blog page.

When we implement lazy loading, most of your store is good for the future and will automatically lazy load images, except blog posts or pages where you enter content in the Shopify editor.

But don’t sweat it, we show you how to manually add lazy loading so you can use this on article pages too (and get those blog posts lighter to get better ranking).

What’s Next?

If you landed here looking to optimize your Shopify site, here are some other tips for speed gains:

  • Automatically compress your images with Crush Pics
  • Make sure you’re using JPG image format instead of PNG for photographic images (PNG’s are often 2x – 10x larger for the same resolution
  • Run your site through the Shopify Analyzer to see what optimization opportunities you have, and how to approach them

If you’re interested in optimization services done for you by one of our Shopify Optimization Specialists, head over to our Shopify Optimization Services page to see how we can help.