Bad evaluation LCP and Best Practices on picture tag
See original GitHub issueOn this page (https://www.kortic.com/photographie/skateboard-volant.html) , Lighthouse matches only the src tag and ignores the source tags. So LCP is wrong. It says :
Largest Contentful Paint element 1 element found
Skateboard (volant) <img decoding="async" loading="lazy" src="/images/card/950/643c16e4/skateboard-volant-2.jpg" alt="Skateboard (volant)" aria-labelledby="imgContentInfo" itemprop="contentUrl">
Additionnaly, the evaluation of best practice “Serves images with low resolution” is wrong too on the same element : Displayed size | Actual size | Expected size 360 x 360 | 420 x 420 | 945 x 945
However, only the “/images/card/420/643c16e4/skateboard-volant-2.jpg” is loaded on mobile.
The original source is :
<picture>
<source media="(max-width: 29.9375rem)" srcset="/images/card/420/643c16e4/skateboard-volant-2.jpg">
<source media="(min-width: 30rem) and (max-width: 63.9375rem)" srcset="/images/card/500/643c16e4/skateboard-volant-2.jpg">
<img decoding="async" loading="lazy" src="/images/card/950/643c16e4/skateboard-volant-2.jpg" alt="Skateboard (volant)" aria-labelledby="imgContentInfo" itemprop="contentUrl">
</picture>
Issue Analytics
- State:
- Created 3 years ago
- Comments:17
Top Results From Across the Web
Largest Contentful Paint Examples & Best Practices
As part of Core Web Vitals, the Largest Contentful Paint (LCP) score measures the perceived loading speed of a website.
Read more >How To Improve Largest Contentful Paint (LCP) on WordPress
By improving their loading time, you'll boost the Largest Contentful Paint performance. Here's what you can do to fix any performance issues about...
Read more >Optimize Largest Contentful Paint - web.dev
A step-by-step guide on how to break down LCP and identify key areas to improve.
Read more >How To Optimize Websites for Largest Contentful Paint (LCP)
In this post, we'll take an in-depth look at Largest Contentful Paint and outline the best practices you need to know to optimize...
Read more >What is Largest Contentful Paint? How to Fix LCP Issues?
Background images with CSS. Text elements, such as paragraphs, headings, and lists. Images. Image tags. Video thumbnails. If slow resource load ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I made a minimal repro here: https://misc-hoten.surge.sh/lh-11895-picture-lcp/
The
picture
element actually does not work without an accompanyingimg
element. Try removing themedia
attributes + removing theimg
element: you’d expect the firstsource
image to be used, but nothing is drawn, because there’s noimg
. Theimg
element is the container used to draw apicture
.Since the LCP element should be the element where the largest content is drawn, identifying the
img
insidepicture
seems to be working as intended. I’ll reach out to folks on the Chrome metrics team and confirm if this behavior is intentional.Some things Lighthouse team should check:
img
insidepicture
? At least delete thesrc
in the snippet, or just point to thepicture
instead?img
element? I see we do in at least one place (preload-lcp-image)–is there also something in Lantern?This audit doesn’t check if an image element has an associated network resource. We just assume any image element is fair game to analyze. There is a filter for “is this image in the initial viewport”, so I think we can argue that we should also filter out “invisible” img elements (I mean–verify that an image element actually has a network request for its
src
).Lighthouse team: it seems we want to do a normalization pass when using
artifacts.ImageElements
, to take in account thepicture
behavior. Are there places other thanimage-size-responsive
we need to apply this?Thanks, wasn’t sure if it was this issue or not. Will raise another.
Thanks