-
Notifications
You must be signed in to change notification settings - Fork 128
Description
As discussed in #1928 (comment):
(Granted, this might be able to be refactored so that it happens at
initialize()
, so that in thehandleLCPMetric()
function it calls theextendRootData()
function every time. This would depend on passingextendRootData()
andextendElementData()
toinitialize()
and we'd need to defineurlMetric
earlier. This would allow Image Prioritizer to get rid of itsexternalBackgroundImages
variable since it would be directly putting the LCP data into theurlMetric
whenever a new one is detected.)
This becomes more important when considering that if the browser is asked to do too much work during pagehide
it may terminate execution of the function. See #1928. So the earlier we amend the URL Metric data the better.
These are the relevant properties of FinalizeArgs
:
performance/plugins/optimization-detective/types.ts
Lines 77 to 83 in 47eef00
readonly getRootData: () => URLMetric; | |
readonly extendRootData: ( properties: ExtendedRootData ) => void; | |
readonly getElementData: ( xpath: string ) => ElementData | null; | |
readonly extendElementData: ( | |
xpath: string, | |
properties: ExtendedElementData | |
) => void; |
We need to include them in InitializeArgs
.
Then we'll need to move the client extension initialization logic down to occur after:
performance/plugins/optimization-detective/detect.js
Lines 682 to 689 in 47eef00
urlMetric = { | |
url: currentUrl, | |
viewport: { | |
width: win.innerWidth, | |
height: win.innerHeight, | |
}, | |
elements: [], | |
}; |
Aside:
Let's add logging for each extension that is loaded.
We should also remove this old log entry (cf. d2e266d):
log( 'Detection is stopping.' ); |
Lastly, let's move this line up to a more logical spot to right after it is last used (see 4025e61, although it should be placed right after disconnectIntersectionObserver()
):
performance/plugins/optimization-detective/detect.js
Lines 888 to 889 in 47eef00
// Clean up. | |
breadcrumbedElementsMap.clear(); |
Finally, we should deprecate finalize
because we cannot reliably compress the URL Metric data at pagehide
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status