Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Good day all!
I regularly work on my website speed and recently PageSpeed Insight told me that my Image elements do not have explicit width and height
It specifically pointed out the images on my home page.
How do I set an explicit width and height on image elements (for the images on the home page and other pages) to reduce layout shifts and improve CLS.
my website
PageSpeed Insight
Thank you so much!
Hello @MPDetailing,
You can check the documentation below for detailed information about this issue and how it can be resolved.
https://web.dev/optimize-cls/?utm_source=lighthouse&utm_medium=lr#images-without-dimensions
Let us know if you need any further help with this issue or with Shopify.
All the best,
CedCommerce
Hello @MPDetailing,
I'm Gina - Product Manager at flareAI. flareAI has helped Shopify stores generating $5 million in sales from Google Search, on autopilot.
If it's helpful to you, please let me know by giving it a like or marking it as a solution.
You can add the image's native width and height in pixels as attributes on the image. This lets the browser calculate the aspect ratio for the image.
<img width="600" height="400" src="https://cdn.shopify.com..."/>
For more information, you can go through this guide and also check this documentation of the image object and you can get the width and height from it.
If you found the answer helpful consider supporting the Shopify Community by giving it a Like + Accept the solution.
Gina
flareAI
Hi there,
For more infomation, pls kindly check the link below
https://www.shopify.com/partners/blog/img-url-filter
or
https://web.dev/optimize-cls/?utm_source=lighthouse&utm_medium=lr#images-without-dimensions
Get know us at: Website | Blog | FAQ | Contact us
The year-end shopping spree is around the corner! Is your online store ready for the ...
By JasonH Nov 10, 2024We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024