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

core(preload-lcp-image): fix faulty request chain exclusion logic #14404

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

connorjclark
Copy link
Collaborator

@@ -1797,45 +1797,8 @@
"displayValue": "",
"details": {
"type": "opportunity",
"headings": [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delta here shows the new logic is WAI, as this image is directly requested by the main document.

image

https://www.mikescerealshack.co/corrections

@brendankenny
Copy link
Member

For the smoke failure: added an additional issue to #14300 (comment) that I believe has come up in the past but I couldn't find written down anywhere. A dynamically-loaded image with img.loading = 'lazy' set on it will lose the networkRequest initiator information, but lantern will try to recover and still at least include it connected to the root request.

That's what's causing the test to think that it was a single hop from html->image even though it's actually delayed-element.js adding the image to the page (the imgEl.loading = 'lazy'; line was added later when the lcp-lazy-loaded audit was added).

@connorjclark
Copy link
Collaborator Author

Should we just mark this audit n/a if the LCP element initiatorRequest is undefined, and just 100% defer to lcp-lazy-loaded?

// this case for this audit.
if (request.initiatorRequest) {
// It's already discoverable from the main document, don't recommend it.
if (initiatorPath.length <= mainResourceDepth + 1) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this +1 for the redirect request? What if there are multiple redirects?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is addressing the first bullet point of #14300. The mainResourceDepth variable accounts for the redirects.

@brendankenny
Copy link
Member

brendankenny commented Sep 21, 2022

Should we just mark this audit n/a if the LCP element initiatorRequest is undefined, and just 100% defer to lcp-lazy-loaded?

Should it be a warning instead? I'm not sure how often and in what circumstances Chrome loses initiator info, but

  • it would be nice to query that via HTTP Archive, and
  • n/a kind of lets the site off the hook. At least for lazy loading, (AFAIK) the only way for this to happen is for the image to be added by JS, so we know it's at least not discoverable in the main document, we just can't calculate the opportunity.

return {
score: ByteEfficiencyAudit.scoreForWastedMs(wastedMs),
score: missingInitiator ? 0 : ByteEfficiencyAudit.scoreForWastedMs(wastedMs),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brendankenny should I be doing something else here?

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

Successfully merging this pull request may close these issues.

None yet

3 participants