I am trying to improve my website speed score, and the biggest hindrance is the Largest Content Painful which is taking a long time to load as it is set to lazy loading. I am using the origin theme for my website floraflourish.com. Can you help me remove lazy loading for all content above the fold across my website please?
The LCP identified here is the first image on my homepage.
Ok. It seems like you have lazy loading set up for multiple images on your website.
To remove this, go to the code editor, and for each section that you’re trying to edit, look for the code block section.settings.image and under there, remove loading: ‘lazy’.
I’ve seen this guide, and it doesn’t quite help. The sections I am trying to remove lazy loading for are ‘featured product’ and ‘product information’ in the origin theme. When I go to edit code, the sections ‘featured-product.liquid’ and ‘main-product.liquid’ don’t have loading=lazy in them. The ‘main-product.liquid’ has lazy_load: false. That’s about it.
The only sections with loading=lazy are image-banner.liquid and image-text.liquid which i’m not sure if are the right sections?
Also, the snippets product files have loading=lazy in them, but i don’t know which to remove. And do I delete it or change loading=lazy to loading=eager?
Hope you can help pinpoint the exact file and code I need to amend.
It’s hard to see exactly where lazy loading is on a Shopify website since blocks are used, and can be used multiple times on a website. And you wouldn’t want to remove lazy loading throughout the whole website, just above the fold.
Paste this code in the two files you want to edit:
{% if image_above_fold %}
// Your image code without lazyload
{% else %}
// Your image code with lazyload
{% endif %}
This code is looking at if the image is above the fold or not and whether or not to add lazy loading.
Thanks for this. I tried pasting it in featured-product.liquid, but I still get the LCP loading lazily diagnosis when i ran the page speed test. Furthermore, I get a weird comment showing up at the bottom right on my site. Images below.
I tried pasting it in the theme.liquid file as well, but the speed test still shows that the Largest Content Paint image was loaded lazily.
Maybe I’m placing the code in the wrong place? Could you guide me on where I should place this code exactly to get the outcome I need? Thank you so much!
I have the same issue with above the fold lazy loading, and was wondering if you could have a look and suggest something to try.
Here is the link to the website: www.skindevotee.com and below is the code that is parsed.
So I searched for this and saw that the only file that calls this exact code is in responsive-image.liquid file.I don’t know how to insert the logic you provided in the above posts you mentioned to force the hero-image on the homepage to not lazy load.
Here is the code for the responsive-image.liquid
Thank you
Neil
{%- comment -%}
Pass these variables into snippet:
Required:
image: Image object
sizes: srcset size attribute
Optional:
prioritize_loading: is this image rendered above the fold or otherwise prioritized? this will avoid loading=“lazy”
fallback_width: width shown to browsers that don’t support srcSet
tag_name: render something other than an img element, for instance picture or source
media: custom media definition for source
aspect_ratio: necessary if the image is displayed at a non natural aspect ratio
fallback_alt: fall back alt text if non set on image in admin
src_set_type: optional parameter used to reduce the srcset generation to speed up page perf
‘grid’
‘full-width’
if unset a comprehensive src set range will be used
{%- endcomment -%}
{%- liquid
if tag_name == blank
assign tag_name = “img”
endif
if fallback_width == blank
assign fallback_width = 320
endif