Skip to content

core(crc): exclude non network nodes from being a leaf #9801

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

Merged
merged 6 commits into from
May 3, 2022

Conversation

paulirish
Copy link
Member

I ran LH on nytimes and noticed data uris in the crc graph:
image

They seem out of place.

To me, CRC is about optimizing network load, but datauris are inlined into the parent request, so I dont think it's fair to report them in here.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

What does this mean for data urls that load more stuff from the network? Is the critical chain dropped there anyways or does it properly attribute initiation to the thing containing the data url?



it('discards datauris as non-critical', () => {
const networkRecords = mockTracingData([HIGH, HIGH, HIGH], [[0, 1], [0, 2]]);
Copy link
Contributor

Choose a reason for hiding this comment

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

network-records-to-devtools-log.js does this a lot better :)

@@ -104,8 +104,6 @@ class UsesRelPreloadAudit extends Audit {
if (request.isLinkPreload) return false;
// It's not critical, don't recommend it.
if (!CriticalRequestChains.isCritical(request, mainResource)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

isCritical should really be on NetworkRequest or something

@patrickhulce
Copy link
Collaborator

What does this mean for data urls that load more stuff from the network? Is the critical chain dropped there anyways or does it properly attribute initiation to the thing containing the data url?

I would be shocked if the initiator is properly attributed to a data URI. Even if it were, I would also be shocked if there were ever a situation in which a chain of critical requests came from a data URI resource. I'm not sure I can recall a time I've seen a critical stylesheet or script served as a data URI instead of just being inlined.

If we're concerned about this, I'd prefer to build a separate audit that says "why on earth did you ship a critical resource that's not a font or image as a data URI" 😆

@brendankenny
Copy link
Contributor

I would be shocked if the initiator is properly attributed to a data URI. Even if it were, I would also be shocked if there were ever a situation in which a chain of critical requests came from a data URI resource. I'm not sure I can recall a time I've seen a critical stylesheet or script served as a data URI instead of just being inlined.

If we're concerned about this, I'd prefer to build a separate audit that says "why on earth did you ship a critical resource that's not a font or image as a data URI" 😆

so I couldn't resist and just did an http archive query for this, and there are sites that do this :)

Whether or not including them is a good thing on our part becomes the operative question, I guess. One example:

example critical request chain

https://googlechrome.github.io/lighthouse/viewer/?gist=63e85fa1861ab1cc73248d12ad3d1ab7

@patrickhulce
Copy link
Collaborator

Color me shocked 😱

C'mon livingspaces, seriously!?

@brendankenny
Copy link
Contributor

brendankenny commented Oct 9, 2019

one way out of this: this PR is really about fixing data URLs as critical requests themselves, not if they should be part of the critical chain. We discard a critical request from the chain here if any ancestor isn't critical; we could change that to be if any ancestor isn't critical and isn't a data URL, so chains going through a data URL will be preserved, but data URL leaves won't be included as intended by this PR.

@patrickhulce
Copy link
Collaborator

I personally don't think it's worth fixing just for this visualization, but that solution works for me if y'all do.

@brendankenny
Copy link
Contributor

I personally don't think it's worth fixing just for this visualization, but that solution works for me if y'all do.

worth fixing which? The whole PR or my suggestion? :)

@patrickhulce
Copy link
Collaborator

worth fixing which? The whole PR or my suggestion? :)

Oh just not worth fixing the specific issue where data URL descendants disappear, so your suggestion :)

PR still seems fine to me as-is coupled maybe with a new audit to tell livingspaces to stop being so cray cray

@patrickhulce
Copy link
Collaborator

@connorjclark is this assignment meant for me to pickup the committer portion?

@connorjclark
Copy link
Collaborator

connorjclark commented Sep 2, 2020

No, you were the reviewer, but this was before git3po assigned people, so I'm just updating assignee. Next action is still Paul.

@connorjclark
Copy link
Collaborator

#9801 (comment) SGTM. Paul, still want to do this?

@patrickhulce patrickhulce removed their assignment Nov 15, 2021
@connorjclark connorjclark self-assigned this Apr 25, 2022
@paulirish paulirish requested a review from a team as a code owner April 26, 2022 00:16
@connorjclark
Copy link
Collaborator

I updated the branch.

@connorjclark connorjclark changed the title core(crc): don't consider datauris to be critical requests core(crc): exclude non network nodes from being leaf in critical chain Apr 26, 2022
@connorjclark
Copy link
Collaborator

best attempt at a commit title, anyone wanna try improving?

@connorjclark
Copy link
Collaborator

@paulirish @brendankenny one of you should review this now that I rewrote it.

Copy link
Member Author

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

seems good! it wasnt immediately obvious why the L121 check only affected leaf nodes but it made sense after a bit.

nice.

lgtm (the UI wont let me approve)

@connorjclark
Copy link
Collaborator

seems good! it wasnt immediately obvious why the L121 check only affected leaf nodes but it made sense after a bit.

what's funny is that it still doesn't make sense to me, but hard to argue with the tests.

@connorjclark connorjclark changed the title core(crc): exclude non network nodes from being leaf in critical chain core(crc): exclude non network nodes from being a leaf May 3, 2022
@connorjclark connorjclark merged commit 4390017 into master May 3, 2022
@connorjclark connorjclark deleted the crcnonnetwork branch May 3, 2022 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants