-
Notifications
You must be signed in to change notification settings - Fork 107
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
Allow extensions to opt-in to using the web-vitals attribution build via the od_use_web_vitals_attribution_build
filter
#1759
Conversation
plugins/optimization-detective/class-optimization-detective-debug-tag-visitor.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/class-optimization-detective-debug-tag-visitor.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/class-optimization-detective-debug-tag-visitor.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/class-optimization-detective-debug-tag-visitor.php
Outdated
Show resolved
Hide resolved
plugins/optimization-detective/class-optimization-detective-debug-tag-visitor.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
With fresh eyes I was able to fix the anchor positioning and styling a bit. This looks much better now: Screen.Recording.2025-01-10.at.15.42.34.movOf course it needs a lot of tidying up still, but it seems to more or less work. Now we just need to figure out where to put all of this code. don't necessarily like putting it into its own GitHub repo where it's not easily discoverable. Aside: There is one test failure now:
🤔 |
Humm. Yeah. There's a similar issue for what to do if content is added to the page by JS and the slow interaction occurs for an element in that added content. Basically, we can't rely on the This, however, won't address the related problem of the |
Sounds good. I started extracting the relevant code to https://github.com/swissspidy/od-debug-helper and made this PR all about adding the web-vitals.js attribution build. What's missing is passing the INP data to OD extensions. --
Yes I think so. |
Something else to consider is to not rely on the selector as provided by the attribution build but rather to construct an XPath to the element using the same scheme the plugin uses server-side. This would eliminate reliance on the class names to select the element. It would likely, however, break in other ways, such as when JS adds or removes nodes preceding the node in the tree. |
Yes, I thought about that too but found it too cumbersome at first. But I now just got Gemini to write a DOM element -> XPath selector for me so now I guess I'll use that one for now :) Then I don't need any JS to query by selector for now. While it won't address the case of dynamically added elements, I think that's good enough for now for this debug helper. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
/** | ||
* | ||
* @param {LCPMetric|LCPMetricWithAttribution} metric | ||
*/ | ||
( metric ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But your PhpStorm clearly only sees LCPMetric
, not LCPMetricWithAttribution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
What's strange to me is why this typing is even needed.
With 3614c13 I added more typing for the attribution report functions. Then PHPStorm reports that the arg is detected as a LCPMetricWithAttribution
:
But TypeScript is giving a warning about it being implicit any
:
Nevertheless, onLCP
is defined as being either OnLCPFunction
or OnLCPWithAttributionFunction
:
So I would have thought that this would be later be reflected in the type of the arg here. But instead it is showing up as any
, even though the common ReportOpts
arg is carried through:
Co-authored-by: Weston Ruter <westonruter@google.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
od_use_web_vitals_attribution_build
filter
Summary
Fixes #1736
Idea: add a "dot" on relevant elements (e.g. LCP elements). Click on the dot to learn more about the element.
Relevant technical choices