Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello Community,
Would anyone be able to please help me add a preloading tag for LCP. I use Flex theme.
Thankyou.
Solved! Go to the solution
This is an accepted solution.
Hi @MrsMacca
To preload your Largest Contentful Paint (LCP) image, use the <link rel="preload"> tag in the HTML header with the as="image" attribute and the image's href attribute, and optionally include fetchpriority="high" for priority loading.
Here's a breakdown:
1. <link rel="preload">: This tag tells the browser to start fetching the resource (in this case, the LCP image) early in the page load process.
2. as="image": This attribute specifies that the resource being preloaded is an image.
3. href="path/to/your/image.jpg": This attribute specifies the URL of the image to preload.
4. fetchpriority="high" (optional): This attribute, when included, instructs the browser to prioritize the image download, ensuring it loads quickly.
Add the code below after <head> 👇
<link rel="preload" href="path/to/your/image.jpg" as="image" fetchpriority="high">
You can find more info. Here: https://web.dev/articles/preload-responsive-images
This is an accepted solution.
Hi @MrsMacca
To preload your Largest Contentful Paint (LCP) image, use the <link rel="preload"> tag in the HTML header with the as="image" attribute and the image's href attribute, and optionally include fetchpriority="high" for priority loading.
Here's a breakdown:
1. <link rel="preload">: This tag tells the browser to start fetching the resource (in this case, the LCP image) early in the page load process.
2. as="image": This attribute specifies that the resource being preloaded is an image.
3. href="path/to/your/image.jpg": This attribute specifies the URL of the image to preload.
4. fetchpriority="high" (optional): This attribute, when included, instructs the browser to prioritize the image download, ensuring it loads quickly.
Add the code below after <head> 👇
<link rel="preload" href="path/to/your/image.jpg" as="image" fetchpriority="high">
You can find more info. Here: https://web.dev/articles/preload-responsive-images
what would the path to my image look like, where would i find it please?
Thankyou, I worked it out, it seems to have worked
hi @MrsMacca
To add a preload tag for your Largest Contentful Paint (LCP) element in the Flex theme, follow these steps:
Use Google PageSpeed Insights or Lighthouse (in Chrome DevTools) to find your LCP element. It’s usually an image, video, or heading text.
<link rel="preload" as="image" href="{{ 'your-image.jpg' | asset_url }}" type="image/jpeg" />
If the LCP element is a font, use:
<link rel="preload" as="font" href="{{ 'your-font.woff2' | asset_url }}" type="font/woff2" crossorigin="anonymous" />
If your LCP element is an image, also add loading="eager" and fetchpriority="high" in the <img> tag to boost loading speed.
Dotsquares Ltd
Problem Solved? ✔ Accept and Like solution to help future merchants.
Hi @MrsMacca
If the solution presented meets your needs and effectively addresses your query, I encourage you to accept it as the chosen answer. This will acknowledge your support and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025