If you find lazysizes in your Shopify theme, it is probably part of the way images are loaded. It is not automatically an error or a script you should delete. The right decision depends on which theme components still rely on it.
Modern browsers support native lazy loading, which can simplify ordinary image loading. Older themes may also use lazysizes for responsive sizing, background images, sliders or content added after the initial page load. Those dependencies need a deliberate review.
What lazysizes does
Lazysizes is a JavaScript library that detects when eligible content should load. A common setup uses a lazyload class with data-src or data-srcset attributes. The script turns those deferred values into the image sources the browser requests.
The library also supports responsive images and optional extensions. The official lazysizes documentation describes these patterns. That is why removing its script without updating the associated markup can leave product images empty.
How native lazy loading differs
With native image lazy loading, an image has its real src and any responsive srcset in the HTML, plus loading="lazy" when deferral is appropriate. The browser decides when to fetch it. There is no separate lazy-loading library required for that basic behavior.
Native loading does not automatically replace every custom behavior supplied by a theme or a lazysizes extension. CSS background images and specialized galleries need separate attention. See the browser-level image lazy loading guide for the native approach.
When keeping lazysizes can be sensible
Keep it while you investigate if your theme’s galleries, quick-view panels, collection filters or responsive sizing depend on it. A working implementation is preferable to an incomplete migration made solely to remove one script from a speed report.
The first task is to identify the dependency, not to decide that all JavaScript is bad. Check whether the library loads once, whether it is genuinely used and whether another app or theme feature is also controlling the same images.
When native loading may be a better fit
Native loading can be a clean option for ordinary below-the-fold product cards and content images when the theme can output complete image markup. It can reduce the need for a separate script to manage those elements.
Before making the change, confirm that responsive image sizes, reserved dimensions and gallery behavior remain correct. An image that loads successfully but arrives at an unnecessarily large resolution still deserves attention. Our Shopify image optimization guide explains those related choices.
Do not lazy-load the main visible image by default
The first product image or prominent hero image often supplies the page’s Largest Contentful Paint. Delaying it until a script initializes or a lazy-loading threshold is reached can hold back the content a shopper came to see.
Identify the actual LCP element in a test. Give that important image appropriate initial loading treatment, and reserve lazy loading for images that can wait. The exact implementation depends on your theme. Our Shopify lazy loading guide covers this distinction.
A safe review and migration checklist
- Duplicate the theme. Make the change on a working copy so you can compare and roll back.
- Map the dependencies. Search the theme for lazysizes, lazyload classes, deferred source attributes and related extensions. Include dynamically loaded sections.
- Update one component first. If migrating, give its images valid sources and responsive attributes. Do not remove the shared library while other components still require it.
- Test the complete gallery. Check thumbnails, zoom, variant images, sliders and images revealed after opening panels.
- Check mobile and desktop. Scroll through collections, change filters and revisit the page with cached assets.
- Compare performance and functionality. Use the same URLs and test settings. Confirm that important images appear promptly and later images still load.
What a successful result looks like
All expected images appear, the main product content is not unnecessarily delayed, responsive sizes remain appropriate and the page does not jump as images arrive. A smaller script list is useful only when the storefront experience still works.
For a consistent before-and-after process, follow our Shopify speed test guide. If the theme has several loading systems or custom interactions, our manual optimization service can review the dependencies and implement the changes with validation.
Choose loading behavior based on the content and the theme’s requirements. Keep what is needed, simplify what is redundant and verify the shopping journey before launching.