-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The image loading attribute depends only on the fetchpriority value #393
The image loading attribute depends only on the fetchpriority value #393
Conversation
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
Hi @cavaglieridomenico , first of all, thanks for the PR. To accept that, we will have to discuss some points.
|
Hi @iago1501, thanks for your feedback and insight into the performance topic. I usually work on many VTEX accounts (itwhirlpool, frwhirlpool, bauknecht, etc.). Otherwise many other PLPs do not contain any banner image and the first product-card image is the LCP element. To analyze the second case we can use this URL as an example: Before 2024-07-30: After 2024-07-30: The aim of this PR is to achieve the possibility of managing the following cases:Case of PLP without banner image Case of PLP with banner image Case of product-card image on shelf CLS in rendering product-card images is usually quite controlled using min-height rules. |
Hi @cavaglieridomenico , I will agree with this PR, mainly because auto doesn't exist, and lazy should be the correct behavior instead of auto. But, I only have some concerns about it. When I changed the way you did, I just found some important metrics running through lighthouse on devtools, here they go: When adding loading lazy in elements above the fold, it triggered a warning regarding a delay in largest contentful paint, which makes sense. The LCP will always be the LCP no matter if it's loaded lazy or not. The way it makes more sense, it's using the prop that we have thinking about performance optimization in fetching priority, which is byPosition. This prop will give higher render priority for the first images (above the fold), giving high priority, the browser will have high priority when downloading (better TTFB). Check loading attribute, the recommendation is to only add it in images that are positioned below the fold: https://www.w3schools.com/tags/att_img_loading.asp When checking the delay in LCP, we can find these information: The worst aggressor for the content is the TTFB for the assets, when checking load and render metrics, they are responsible for only 6% of the LCP, so, for a better metric on that, we should check for a better cache policy on the images maybe or something on the assets server. But, I agree with you that the shouldResize doesn't look useful and there's no auto in loading attribute, but, keep in mind that this implementation might not affect your use case about an increase in LCP. Another important references that might also be useful to understand: https://web.dev/articles/lcp-lazy-loading?utm_source=lighthouse&utm_medium=devtools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TL;DR;
- shouldResize doesn't look useful for not loading eager
- loading attrib doesn't have auto
- This might not reduce LCP of the page (check above evidences)
Your PR has been merged! App is being published. 🚀 After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:
After that your app will be updated on all accounts. For more information on the deployment process check the docs. 📖 |
What problem is this solving?
Currently resizing the images in the product-summary automatically sets the images to load lazy.
This behavior represents a performance issue especially in PLPs since the first product-summary image is usually the LCP element and if width and height are specified (obtaining the correct image size via CDN) the LCP element loads lazy (degrading LCP score).
The suggestion is to connect the
loading
value (without new props via CMS) to thefetchpriority
value (which already has correct logic and props via CMS).Furthermore, this feature removes the
auto
value that is not present in the possibleloading
attribute values (HTMLImageElement: loading property).How to test it?
Workspace
Screenshots or example usage:
Production
Workspace