-
Notifications
You must be signed in to change notification settings - Fork 104
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
Explore opportunities to use Optimization Detective to identify INP problems #1736
Comments
Thanks for starting the discussion on this! Thinking out loud a bit: We probably won't have a dashboard like #1324 anytime soon and even then it is not necessarily the best way to expose INP info, at least not on its own. Something that works on the frontend would be really cool. The admin bar came to mind as some performance or statistics plugins hook into that (e.g. Site Kit). And elements could be highlighted if they are visible. This could be done in some sort of "debug mode" if you are logged in and visit a URL where INP info is available.
If the relevant INP elements are present on the page, we could visually highlight it somehow (background color, outline, a glowing dot, etc.). We could even do that with the LCP elements too. An admin bar menu item can show you the current collected field data, maybe even for all viewports. It could show the relevant selectors for the affected elements for easier debugging, and then maybe just point to some documentation to help with debugging. Bonus points for proper attribution of the plugin/theme/block responsible for that element. Example of the Site Kit admin bar menu item: I feel like such a small admin bar integration would already be very helpful. Even for us working on Optimization Detective it could be useful to see the numbers right there on the page. |
Debug helpers could also surface data added in #1742 |
I love this. Perhaps this would also be a great chance to use the anchor positioning API to add annotations with each element that is being highlighted, e.g. "LCP on mobile" or "Slow interaction target". For highlighting elements involved in slow interactions, I suppose this could be implemented by injecting a One complication for LCP would be the fact that the URL Metric stores the XPath of the elements and these can easily become invalid. For example, when the admin bar is shown it inserts the But for INP since CSS selectors are what web-vitals.js exposes, then the issue should be minimized. Also, currently Optimization Detective isn't using the attribution build of web-vitals.js, since they haven't been needed. Maybe we should have a way to opt-in to the attribution build if an extension needs it. |
I started looking into that a bit today and try to come up with a prototype this week for further discussion.
Yeah for simple outline or so that would be enough. However...
...that means we'll need to add some extra element for a tooltip that we can position & anchor. For LCP elements I can do that server-side with a tag visitor, but for INP elements we only have a selector, so this would need to be done client-side I presume.
Yeah that was my thinking, or only if you enabled debug mode or so. We can experiment with that.
Annotating LCP elements with a tag visitor seems to be relatively trivial so far.
👍 |
Do you have a repo for this? |
I was working directly in the optimization-detective plugin and will open a PR when it‘s more shareable. Then we can discuss where it should live :) |
I do have three extension plugins which I have repos for under my account:
Originally I had thrown these up in gists but I moved them over to proper repos for collaboration. These don't seem like they would make sense as part of the Performance repo. But for an extension that helps detect INP issues, maybe it would? |
Oh I didn't know, thanks for sharing! That could be an option for such a debug helper as well, though one could argue whether it should be part of OD itself (behind a flag or so). |
Haven't actually added the INP part yet, but I just opened #1759 with what I had in mind so far. |
Optimization Detective is currently being used to optimize LCP via Image Prioritizer and CLS via Embed Optimizer. However, for the other Core Web Vital, INP, it is not currently doing anything. This is somewhat expected given that there isn't really an element which can be optimized for INP issues like there can be for LCP and CLS. Nevertheless, Optimization Detective does provide a foundation for at least tracking INP issues:
onINP
function as provided by Web Vitals.od_url_metric_schema_root_additional_properties
filter to add a new root property for something likeinpData
.od_url_metric_stored
action which is fired whenever a new URL Metric is stored. An extension could use this to grab the INP data out of the URL Metric and store it persistently in another location so it is not garbage-collected when a new URL Metric is collected. For example, theOD_URL_Metric_Store_Request_Context
object passed to theod_url_metric_stored
action includes not only theOD_URL_Metric
instance but also the post ID for theod_url_metrics
post type that the URL Metric is being stored in. An INP-focused extension could use this to persist the INP data in postmeta for that post, likeod_inp_data
:We can then get all of the INP data with:
The question then remains: with this data in hand, what do we do with it?
Assuming we have something on the page that causes a long task:
The INP data provided by Web Vitals includes:
Do we capture these and just provide a UI to view them? Do we list the counts in the admin bar and show them when clicked? Do we highlight the elements on the page which are involved in slow interactions (if they are even present)? Or do we expose a dashboard for this information as explored in #1324?
Related: #1730
The text was updated successfully, but these errors were encountered: