Preconnect links for embeds need not require URL Metrics to be collected from both mobile and desktop #1757
Labels
[Plugin] Embed Optimizer
Issues for the Embed Optimizer plugin (formerly Auto Sizes)
[Type] Bug
An existing feature is broken
Milestone
Bug Description
On my blog I have a post with a YouTube video in the initial viewport. I'm seeing
preconnect
links added with media queries as expected:This was implemented in #1654 to fix #1341.
However, I was confused when testing because I wasn't seeing any preconnect links added even after a URL Metric had been collected. The small problem in the implementation is that it requires for there to be URL Metrics for both mobile and desktop to be collected before it adds the preconnect links. This was a carryover from before when there were no media queries, so it was needing to make sure the embed is on both desktop and mobile. Now, however, since there are media queries that target the preconnects more granularly, this is no longer required. The requirement that there be URL Metrics collected for desktop and mobile is, however, still required for determining whether to lazy-load.
This is the code in question:
performance/plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php
Lines 107 to 195 in f5f50f9
I believe the code should be refactored like this:
We should also take this opportunity to extract the preconnect and lazy-loading logic into separate methods similar to as we have done for
reduce_layout_shifts
.Steps to reproduce
preconnect
links are present.The text was updated successfully, but these errors were encountered: