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

Attributing impact on Web Vitals 🧪 #98

Open
addyosmani opened this issue Jun 12, 2020 · 2 comments
Open

Attributing impact on Web Vitals 🧪 #98

addyosmani opened this issue Jun 12, 2020 · 2 comments

Comments

@addyosmani
Copy link
Collaborator

addyosmani commented Jun 12, 2020

TPW currently does a great job capturing the execution costs of individual third-party scripts.

I'm curious if there's a mechanism we can define for measuring the impact these third-parties have on web vitals. As an example, let's take CLS:

For each Lighthouse run via HTTP Archive/WPT:

  • Check the Cumulative Layout Shift elements audit for the top N DOM elements contributing to shifts *
  • Using some initiator or DOM API patching magic (wild hand waviness), discover what script initiated the injection of each of these DOM elements
  • Visualize attribution in a similar way as is done for script execution

Is this crazy-talk, @patrickhulce ? :)

  • Exploring this type of idea may rely on us being able to craft better 3P CLS attribution in Lighthouse itself first, so feel free to say this is not remotely possible for now. Current CLS audit looks at elements that were shifted but not necessarily why they shifted.
@patrickhulce
Copy link
Owner

Thanks for starting the conversation @addyosmani! :)

Exploring this type of idea may rely on us being able to craft better 3P CLS attribution in Lighthouse itself first

Definitely reliant on functionality in Lighthouse first since we don't get access to raw traces in HTTPArchive, but we can discuss approaches here before bringing a proposal there 👍

Check the Cumulative Layout Shift elements audit for the top N DOM elements contributing to shifts

Please correct me if I'm wrong, but I had thought that this audit and trace event data marks the elements that shifted which is usually not the same as why they shifted. I think what we would want here is for Chrome to expose the IDs of the new content that reflowed the shifting elements down. I'm not sure it's a solvable problem but it would be neat to try.

Using some initiator or DOM API patching magic (wild hand waviness), discover what script initiated the injection of each of these DOM elements

This also feels very difficult, but I think @connorjclark worked on some stacktrace "find where this DOM element came from" magic that might apply here. I think the tricky part is going to be getting the attribution in the middle of the page load which is what I expect you really need for CLS.

Visualize attribution in a similar way as is done for script execution

This sounds great asssuming we can tackle the other two :)

@connorjclark
Copy link
Collaborator

connorjclark commented Jun 12, 2020

yup! https://chromedevtools.github.io/devtools-protocol/tot/DOM/#method-getNodeStackTraces

we could collect stack traces for all the things in trace-elements, and expose as an optional property on Node detail types.

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

3 participants