Consider storing abstract CWV data in URL Metrics not explicitly tied to tracked elements #1730
Labels
Needs Discussion
Anything that needs a discussion/agreement
[Plugin] Image Prioritizer
Issues for the Image Prioritizer plugin (dependent on Optimization Detective)
[Plugin] Optimization Detective
Issues for the Optimization Detective plugin
[Type] Enhancement
A suggestion for improvement of an existing feature
Feature Description
Originally discussed in #1697 (comment).
The Image Prioritizer plugin is capturing LCP element information independent of the elements which are explicitly tracked for capturing in the
elements
of a URL Metric (which is indicated by returningtrue
in a tag visitor). Image Prioritizer needs to do this for prioritizing the background image for an element which is applied with a stylesheet and not via an inlinestyle
. This is because no tag visitor would know which tag to capture in URL Metrics since there is no server-side indication that the element would be LCP or that it would have a background image.All this to say, Optimization Detective only captures LCP information by storing
isLCP
in the element captured in URL Metric. It doesn't store the LCP element's imageurl
or any other information about theLargestContentfulPaint
. This means that Image Prioritizer on its own needs to store theurl
andid
, en lieu ofelement
it stores thetag
name, andclass
name to better identify the element. This information could instead be captured and stored by Optimization Detective for Image Prioritizer to reuse. It could be stored in a top-levellcpElement
property of a URL Metric, alongside the existingelements
.When it so happens that the LCP element was one of the elements captured in URL metrics, then the XPath of that element could be stored in the
lcpElement
property as well (as a nullablexpath
property). As noted above, thexpath
wouldn't necessarily be available since a tag visitor wouldn't know to mark the element for capturing in URL Metrics, so Optimization Detective wouldn't add adata-od-xpath
attribute to the element. No longer wouldisLCP
need to be stored with each item inelements
since the XPath of the LCP element could be stored once inlcpElement
. Determining whether one of the capturedelements
is LCP would then just be a matter of checking if the XPath matcheslcpElement.xpath
.If there is a root
lcpElement
property it may then make sense to generalize this further to have a rootmetrics
property which includes andlcp
,inp
,cls
. For CLS, theLayoutShiftAttribution
sources could be stored for potential reuse by Embed Optimizer (although I think the currentResizeObserver
use in Embed Optimizer is preferable). The actual values for the CWV metrics could also be stored for use by a performance dashboard (#1324).The text was updated successfully, but these errors were encountered: