Re: stop lazy loading in Spotlight

stop lazy loading in Spotlight

Runner
New Member
6 0 0

I am trying to get my site to stop lazy loading images as its slows down my store speed, but I can't find the code in the Spotlight theme I am using to fix that, nor do I know of any other way to stop the images from lazy loading. Any help would be appreciated.

Replies 9 (9)

Dan-From-Ryviu
Shopify Partner
9534 1916 1950

Hi @Runner 

You can do that by finding and removing this part of code loading="lazy" or loading: 'lazy' from liquid files

- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

Runner
New Member
6 0 0

Which liquid files would have those parts of the code? I can not find those parts of the code in my theme.liquid 

Runner
New Member
6 0 0

To clarify on my side, my store's theme, Spotlight, doesn't have the exact lines of loading="lazy" or loading: 'lazy' in any of its liquid files, so I don't know if it would be in another line of code that would stop the lazy loading for images? Or if it's part of a Javascript file?

Dan-From-Ryviu
Shopify Partner
9534 1916 1950

Hi, you can see theme in listed file below:

  • slideshow.liquid
  • product-media.liquid
  • product-media-gallery.liquid

- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

Runner
New Member
6 0 0

Hello @Dan-From-Ryviu!

I appreciate the further guidance, I have found the code in those pages and have removed it, but I am not sure if that has exactly worked as, according to Google Lighthouse, the images are still being lazy loaded. Thoughts on this?

Dan-From-Ryviu
Shopify Partner
9534 1916 1950

Which images? Could you share the link to your page? 

- Helpful? Like and Accept solution! or Buy me coffee
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Ryviu: Aliexpress Reviews - AliExpress Reviews Importer, one-click import aliexpress reviews, export reviews to CSV file.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

Runner
New Member
6 0 0

Yes, here's the link to my page: www.runnersgogear.com 

Runner
New Member
6 0 0

It would be the first few images, that I see are the problem.

Mehran_Ali
Shopify Partner
89 11 11

Try using this script and place it in your theme.liquid file

  1. Log in to Your Shopify Admin:

    • Go to your Shopify admin dashboard.
  2. Navigate to Themes:

    • In the sidebar, click on "Online Store" and then "Themes."
  3. Access Theme Code:

    • Find the theme you want to edit, and click on the "Actions" button.
    • Select "Edit code" from the dropdown menu.
  4. Locate the theme.liquid File:

    • In the code editor, look for the theme.liquid file. It is usually located in the "Layout" folder.
  5. Edit the theme. liquid File:

    • Click on theme.liquid to open it and make your desired changes.
    • Don’t forget to save your changes after editing.

By following these steps, you can access and edit the theme.liquid file in your Shopify store.



 

<script>
$(document).ready(function() {
  // Remove the standard lazy loading attribute
  $('img[loading="lazy"]').each(function() {
    $(this).removeAttr('loading');
  });

  // Remove custom lazy loading attribute (e.g., data-lazy)
  $('img[data-lazy]').each(function() {
    $(this).removeAttr('data-lazy');
  });
});
</script>

 

  Note: make sure you check the attribute in the image tag for lazy load then replace that attribute in the script this will remove all lazy load attribute from the page 

If this solution helps you, kindly like this reply and mark it as a solution.

If you need an expert Shopify developer for customization and development, feel free to contact me via email or WhatsApp.

Email: [email protected]


WhatsApp: +92 343 0211536