question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad evaluation LCP and Best Practices on picture tag

See original GitHub issue

On 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:closed
  • Created 3 years ago
  • Comments:17

github_iconTop GitHub Comments

3reactions
connorjclarkcommented, Dec 29, 2020

I made a minimal repro here: https://misc-hoten.surge.sh/lh-11895-picture-lcp/

The LCP is wrong …

The picture element actually does not work without an accompanying img element. Try removing the media attributes + removing the img element: you’d expect the first source image to be used, but nothing is drawn, because there’s no img. The img element is the container used to draw a picture.

Since the LCP element should be the element where the largest content is drawn, identifying the img inside picture 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:

  • Should we special-case how we show what the LCP element is for img inside picture? At least delete the src in the snippet, or just point to the picture instead?
  • Do we directly use the specific node identified as the LCP for further analysis as an img element? I see we do in at least one place (preload-lcp-image)–is there also something in Lantern?

Additionnaly, the evaluation of best practice “Serves images with low resolution” is wrong …

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 the picture behavior. Are there places other than image-size-responsive we need to apply this?

1reaction
craigs100commented, Feb 3, 2021

Thanks, wasn’t sure if it was this issue or not. Will raise another.

Thanks

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found