Skip to content
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

Should we skip images with an existing LCP entry? #82

Open
yoavweiss opened this issue Oct 3, 2021 · 9 comments
Open

Should we skip images with an existing LCP entry? #82

yoavweiss opened this issue Oct 3, 2021 · 9 comments

Comments

@yoavweiss
Copy link
Contributor

In https://wicg.github.io/largest-contentful-paint/#sec-add-lcp-entry step 2 ensures that elements that already fired an entry will not fire another entry again. I'd like to better understand the reasoning for it, as it seems counter-intuitive, at least in some cases.
e.g. There could be a case where an image A of 50x50 is the LCP, followed by an image B that's 75x50.
If A then gets resized to 100x50, we'd want the largest LCP candidate to be A with the right size, not B.

@npm1
Copy link
Collaborator

npm1 commented Oct 4, 2021

I don't understand how that can happen in the first place. If A is 50x50, how does it suddenly then become 100x50? The only way I can see this happening is if the image container itself is expanded. Since we shrink the images based on intrinsic sizes, it wouldn't affect the LCP size. If instead you mean A gets a different image, then that's a different LCP candidate.

@yoavweiss
Copy link
Contributor Author

One example could be where A is a background image of a node that truncates it, and then gets resized to no longer truncate it (or truncate it less).

@npm1
Copy link
Collaborator

npm1 commented Oct 4, 2021

Oh I see, so this is specific to background images? How often would this happen? Are there use-cases for this? The main reason from my perspective is performance. Also, would this suggest shrinking the size if the candidate is shrank? That would complicate things as we'd have to go back to storing all LCP candidates.

@yoavweiss
Copy link
Contributor Author

I guess this is also true for html-based images that had initially larger intrinsic size than their display dimensions, and were then changed to have larger dimensions.

@yoavweiss
Copy link
Contributor Author

Also, would this suggest shrinking the size if the candidate is shrank?

No, for the same reasons we don't look into removed images.

@noamr
Copy link
Contributor

noamr commented May 13, 2022

Also, due to intersection being part of the size calc, can't a below-the-fold element receive a larger entry while scrolling?
Sounds like this has to happen...

@rik
Copy link

rik commented May 13, 2022

Also, due to intersection being part of the size calc, can't a below-the-fold element receive a larger entry while scrolling?

The algorithm terminates whenever scroll or input events occur, since those are likely to introduce new content into the website.

@noamr
Copy link
Contributor

noamr commented May 13, 2022

Also, due to intersection being part of the size calc, can't a below-the-fold element receive a larger entry while scrolling?

The algorithm terminates whenever scroll or input events occur, since those are likely to introduce new content into the website.

Thanks, of course, I missed that!

@yoavweiss
Copy link
Contributor Author

IMO, there's no strong reason to not fire LCP entries again. The next step is to get a PR going that removes the content set, as well as tests to go along with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants