Description
Feature Description
As discussed in #878 (comment), the Image Loading Optimization module (see #869) has detection logic to discover the LCP image and other images which are in the initial viewport. This logic is currently running at the load
event after which it immediately sends the data to the REST API endpoint:
performance/modules/images/image-loading-optimization/detection/detect.js
Lines 342 to 433 in 03f3252
However, given that the metrics collection is a low priority task which is intended to improve the user experience, we must guard against it from possibly impacting a visitor in a negative way when URL metrics need to gathered. For this reason there is the following todo:
We should leverage requestIdleCallback()
and/or scheduler.yield()
(or else setTimeout
)--whatever is available--to make sure that the detection task is broken up into small tasks that do not contribute to a long task.