chore: add priority to the first product's image on PLP #2293
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's the purpose of this pull request?
Add priority to the 1st product's image on a PLP. It was motivated by a store that was having the performance score penalized on lighthouse because its LCP was the first product on the PLP.
We haven't had found this issue before because our starter has a hero image on PLP (that already has the priority set).
How it works?
On the
ProductGrid
component we send theloading
prop aseager
through theProductCard
component when it's the first product, then on the Image component the priority will be added.How to test it?
yarn dev
and go to http://localhost:3000/technologyhigh
:Comparison
I've compared the LH scores from starter and newstore to check if this change had impacted.
To be fair, I updated those stores to the latest version of faststore core (
3.0.42
) to get the "before" value and updated to this PR version of faststore core (codesandbox) to get the "after" value.Both stores increased 2 points of Performance:
References
next/image
priority
prop