Limit fetchpriority="high" to 2 images on desktop for improved LCP performance #395
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is this solving?
This change optimizes the fetch priority logic for product images by reducing the number of items with
fetchpriority="high"
on desktop from 4 to 3. This adjustment aligns with Google's recommendation for optimal Largest Contentful Paint (LCP) performance, as outlined in this article.According to Google:
By limiting the
fetchpriority="high"
attribute to only the most critical images (3 on desktop), we improve loading efficiency, freeing up bandwidth for other important resources.How to test it?
You can test the change by visiting a product grid in the linked workspace and observing the load times for the images in the first 2 positions. Ensure that only the first 2 images have
fetchpriority="high"
on desktop and the first image on mobile. This can be verified via the browser's DevTools under the "Network" tab.Workspace
Screenshots or example usage:
Production:
Workspace: