Closed kevinfarrugia closed 3 years ago
Is there a guarantee from
IntersectionObserver
that all observed elements will be delivered in one callback? I have not studied the specification deep enough to be sure of that. If there's no guarantee, you might miss some images compared to the previous version.
Converted to draft until I am able to clarify/confirm this.
@kevinfarrugia any update on this?
@rviscomi I had manually tested it on a number of pages and the results are correct. I couldn't find anything detailing whether all entries should be included in the first callback or not, so I suspect it may be up to the browser.
Ok thanks. Is this PR ready for review then? If so I'll try to get it reviewed and merged in time for the September crawl.
Yes it is ready for review but I am wary of merging it until I have a definite confirmation on the behavior of IntersectionObserver.
Ok so let's leave this in draft until you confirm.
Closing for now. Feel free to reopen when ready.
Updated the Images custom metric
inViewport
property to use InteresctionObserver to improve reliability and support for:Inspired by: https://github.com/WPO-Foundation/webpagetest-docs/pull/36
Using IntersectionObserver adds some more complexity because of its async nature, however I tried to keep the custom metric as similar to its previous implementation as possible.
Sample WPT https://webpagetest.org/custom_metrics.php?test=210716_AiDc99_be18dd00ed31c02ef0277471152b0fa8&run=1&cached=0