Switch initial viewport embeds from preconnect to dns-prefetch links#2256
Switch initial viewport embeds from preconnect to dns-prefetch links#2256westonruter merged 15 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @hrishikesh2810. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
westonruter
left a comment
There was a problem hiding this comment.
Thanks for the PR.
I left some feedback.
Note that for the unit test failures, you'll need to update the snapshots. You can do this by first running all the unit tests locally, for example via npm run test-php and then update the snapshots via npm run update-test-case-snapshots. At this point, you should be able to do npm run test-php again, and the tests should pass. You can then commit all the HTML file updates.
|
@westonruter i did run command npm run test-php but it throws this error |
@dhruvang21 Did you follow the setup steps on the handbook page? |
|
@westonruter yes |
|
OK, I'm not sure why it's not working for you. I've updated the snapshots in 16fa2b8 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## trunk #2256 +/- ##
==========================================
+ Coverage 69.32% 69.33% +0.01%
==========================================
Files 90 90
Lines 7746 7749 +3
==========================================
+ Hits 5370 5373 +3
Misses 2376 2376
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Based on @peterwilsoncc's comment, it seems I was overly aggressive in the switch to |
|
@westonruter how should we move further here? |
There was a problem hiding this comment.
Pull request overview
Updates Embed Optimizer’s resource-hint generation to avoid wasted cross-origin preconnect usage by switching affected hints to dns-prefetch, and refreshes related test fixtures across plugins.
Changes:
- Switch Embed Optimizer’s generated resource hints from
preconnecttodns-prefetchfor embed-related hosts. - Extend Optimization Detective’s link-attribute PHPStan type to include
dns-prefetch. - Update Image Prioritizer and Embed Optimizer expected HTML fixtures to match updated output.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/optimization-detective/class-od-link-collection.php | Extends LinkAttributes rel type to include dns-prefetch. |
| plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php | Replaces preconnect-link injection with dns-prefetch-link injection for embeds. |
| plugins/image-prioritizer/tests/test-cases/video-without-poster-lcp-element-on-desktop-only/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/video-with-poster-lcp-element-on-mobile-and-desktop-but-not-tablet/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/video-with-poster-lcp-element-on-desktop-only/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/video-with-poster-lcp-element-on-all-breakpoints/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/video-with-large-poster-and-desktop-url-metrics-missing/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/video-with-large-poster-and-desktop-url-metrics-collected/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/url-metric-only-captured-for-one-breakpoint/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/preload-links-with-one-half-stale-group/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/picture-element-as-lcp-tablet-and-desktop-metrics-missing/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/only-mobile-and-desktop-groups-are-populated/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics-with-non-background-image-style/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics-with-data-url-image/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics-with-data-url-background-image/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics-for-image-without-src/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/no-url-metrics-but-server-side-heuristics-added-fetchpriority-high/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/multiple-videos-with-desktop-metrics-missing/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/multiple-videos-on-all-breakpoints/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/lcp-element-external-background-image-present-in-document-and-partially-populated-samples/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/img-non-native-lazy-loading/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/fetch-priority-high-on-lcp-image-common-on-mobile-and-desktop-with-url-metrics-missing-in-other-groups/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/different-lcp-elements-for-two-non-consecutive-breakpoints/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/different-lcp-elements-for-two-non-consecutive-breakpoints-and-one-is-stale/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/different-lcp-elements-for-non-consecutive-viewport-groups-with-missing-data-for-middle-group/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/different-lcp-elements-for-all-breakpoints/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-old-xpath-format/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/common-lcp-image-with-fully-incomplete-sample-data/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/image-prioritizer/tests/test-cases/background-image-outside-viewport-with-desktop-metrics-missing/expected.html | Updates expected script-tag attribute ordering in fixture output. |
| plugins/embed-optimizer/tests/test-cases/single-youtube-embed-outside-viewport-on-mobile/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-youtube-embed-inside-viewport-with-only-mobile-url-metrics/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-outside-viewport-on-mobile/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-wordpress-tv-embed-inside-viewport/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-twitter-embed-outside-viewport-on-mobile/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-one-group/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/figures-with-fancy-ids/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
| plugins/embed-optimizer/tests/test-cases/all-embeds-inside-viewport/expected.html | Updates expected resource-hint links from preconnect to dns-prefetch. |
Comments suppressed due to low confidence (1)
plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php:284
- Typo in the docblock: "dns-prefech" should be "dns-prefetch".
* Gets dns-prefech URLs based on embed type.
*
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…gin embeds - Update Embed_Optimizer_Tag_Visitor to use dns-prefetch instead of preconnect. - Add support and validation for dns-prefetch in OD_Link_Collection. - Update plugin headers, readme.txt, and documentation for consistency. Co-authored-by: gemini-cli <176961590+gemini-code-assist[bot]@users.noreply.github.com>
westonruter
left a comment
There was a problem hiding this comment.
Sorry for the delay in reviewing this!
Summary
Fixes #2247
Relevant technical choices
dns-prefetchsupport forOD_Link_Collection::add_link()rel=preconnectwithrel=dns-prefetchfor embed resources.