Feature Description
The Embed Optimizer (#888) plugin improves performance for the majority of embeds by lazy-loading them so they don't impede page loading when not in the viewport. However, if they are in the initial viewport the lazy-loading will actually hurt performance by potentially delaying LCP. Any embeds which do not appear in the initial viewport should be excluded from lazy-loading. This can't be done reliably server-side, for example core uses a counter to skip lazy-loading the first N instances. However, Optimization Detective (#869) is built to be able to detect which elements are in the initial viewport so that they can be properly optimized. What is needed is for Optimization Detective to expose an interface for other plugins to hook into the optimization process so that, in the case of Embed Optimizer, it can actually reverse the lazy-loading which it blindly applied server-side for the in-viewport embeds.
Alternatively, the server-side logic for Embed Optimizer could be modified when Optimization Detective is also running to not immediately make the embeds lazy-loaded, but rather to instead mark the embeds with an attribute for the lazy-loading to be applied during post-processing, that is, on the output-buffered page which the HTML Tag Processor iterates over.
Feature Description
The Embed Optimizer (#888) plugin improves performance for the majority of embeds by lazy-loading them so they don't impede page loading when not in the viewport. However, if they are in the initial viewport the lazy-loading will actually hurt performance by potentially delaying LCP. Any embeds which do not appear in the initial viewport should be excluded from lazy-loading. This can't be done reliably server-side, for example core uses a counter to skip lazy-loading the first N instances. However, Optimization Detective (#869) is built to be able to detect which elements are in the initial viewport so that they can be properly optimized. What is needed is for Optimization Detective to expose an interface for other plugins to hook into the optimization process so that, in the case of Embed Optimizer, it can actually reverse the lazy-loading which it blindly applied server-side for the in-viewport embeds.
Alternatively, the server-side logic for Embed Optimizer could be modified when Optimization Detective is also running to not immediately make the embeds lazy-loaded, but rather to instead mark the embeds with an attribute for the lazy-loading to be applied during post-processing, that is, on the output-buffered page which the HTML Tag Processor iterates over.