Repository navigation
Script Loader: Prefetch assets for the next admin screen #13084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
westonruter
wants to merge
77
commits into
WordPress:trunk
from
westonruter:add/admin-script-style-preloading
Closed
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
b3809c8
Preload the admin's unconcatenated assets from the login screen
westonruter 8789351
Prefetch rather than preload the admin's assets from the login screen
westonruter 879ce15
Drop the redundant fetchpriority attribute from the admin prefetch links
westonruter 98b2ee1
Only prefetch admin assets when the login actually leads to the admin
westonruter 0db2f11
Pass the login redirect target to the admin asset prefetch filter
westonruter fa3677e
Prefetch the editor's stylesheets from the screens that lead to it
westonruter cefa78d
Type the handle expander against WP_Dependencies
westonruter 814fcd7
Keep empty handles out of the expanded dependency set
westonruter 6ad32b5
Simplify cap check
westonruter d80705e
Model the prefetch resource list on wp_preload_resources()
westonruter c6c18bb
Stop implying the prefetch filter only takes scripts and styles
westonruter a12640f
Carry each registry alongside the handles it registered
westonruter cec3373
Stop naming the login screen where any screen is meant
westonruter a6ab6ba
Inline the block editor check into its only caller
westonruter 7a646ea
Remove default priority from add_action()
westonruter 8fea842
Say why the URL resolver names two registries and not their parent
westonruter 87e9460
Merge branch 'trunk' into add/admin-script-style-preloading
westonruter 274eb55
Stop claiming prefetch reuse is independent of cache headers
westonruter 9818520
Prefetch only what blocks the admin's first paint from the login screen
westonruter 45e7e8a
Allow far-future caching of static assets in the local environment
westonruter 90d764f
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter 81f72fd
Derive the login prefetch set from root handles
westonruter 8a36ca8
Share URL building between do_item() and the admin prefetch
westonruter 176c7e4
Add tests for WP_Scripts::get_src() and WP_Styles::get_rtl_href()
westonruter a01bb6b
Note where the login prefetch roots are enqueued
westonruter 9b63a14
Drop the redundant wp-pointer prefetch root
westonruter debcf11
Drop the redundant editor prefetch roots
westonruter 68844a5
Note where the editor prefetch roots are enqueued
westonruter 6893636
Add tests for wp_prefetch_admin_assets()
westonruter 35b06f6
Enhance comment on resource attributes in script-loader
westonruter 4524a2d
Fix Copilot's broken indent in 35b06f6479c42caa164f7c269457da5d6313b6a9
westonruter 6368d7a
Clarify when the prefetch URLs may not match the admin's
westonruter 2b11401
Use the login action wp-login.php resolved
westonruter 4e14337
Skip the login prefetch when redirecting to another host
westonruter 30703db
Derive the prefetch tests' URLs from the site's own
westonruter d4f6bf8
Test that network and user Dashboards prefetch nothing
westonruter d40ea0f
Pass stylesheet URLs to the prefetch filter unescaped
westonruter 73bce09
Add WP_Styles::get_src() and rename get_rtl_href() to get_rtl_src()
westonruter c0dcfb9
Check edit_posts rather than create_posts before prefetching the editor
westonruter 89d909c
Prefetch with fetch() in browsers without rel=prefetch
westonruter 21a718e
Share the concatenation default between script_concat_settings() and …
westonruter 49c1fe5
Correct comment formatting in wpShouldConcatenateAdminScripts test
westonruter 88bf79a
Restore the $concatenate_scripts global in tear_down()
westonruter f172c60
Sanitize the right-to-left stylesheet URL only once when printing it
westonruter b00c19c
Skip prefetching from the login screen for an admin under another scheme
westonruter 9b752fe
Skip prefetch URLs that esc_url() rejects
westonruter 20a86b0
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter 5941696
Prefetch from the login screen after its footer scripts
westonruter 329b924
Hook admin prefetching in admin-filters.php
westonruter 34746c5
Check the block editor before prefetching its stylesheets from the lo…
westonruter 52bfff2
Tell the login screen apart by the request, and prefetch on all of it…
westonruter 7105005
Treat an empty redirect_to as none when prefetching from the login sc…
westonruter 2fa8166
Skip what the current screen has queued, not only what it has printed
westonruter 9f0261a
Test the login screen's prefetching with the hooks default-filters.ph…
westonruter ff4c4d1
Check the block editor for the editor's post type in one place
westonruter 20e51e3
Skip expanding the current screen's queue for a type with no roots
westonruter 3e9ae03
Call admin_url() once when resolving the login screen's destination
westonruter 49606b5
Document when to add a wp_should_concatenate_admin_scripts callback, …
westonruter 355774c
Prefetch for a redirect_to of the admin without its trailing slash
westonruter 578f84e
Return the new get_src() and get_rtl_src() URLs unsanitized
westonruter 7257f45
Skip prefetching handles the next screen would print nothing for
westonruter 01353f4
Name WP_Dependencies::add_data() with :: in its deprecation notice
westonruter 368320a
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter d3ea128
Recognize the login screen by 'login_init' rather than is_login()
westonruter 96c9d80
Resolve redirect_to with wp_validate_redirect() alone, as wp_safe_red…
westonruter e4c4eb1
Treat a redirect_to's explicit default port as the admin's own
westonruter acae9f7
Allow only http and https URLs among the prefetched resources
westonruter eb0e614
Clarify which sources WP_Styles::get_src() returns no URL for
westonruter d706ef8
Give the right-to-left stylesheet the same version and arguments as i…
westonruter 81cf946
Merge branch 'trunk' into add/admin-script-style-preloading
westonruter 7fe9568
Name variable to indicate already escaped
westonruter 5a0cfaf
Type the prefetch links in the inline script as HTMLLinkElement
westonruter 8bc35b5
Merge branch 'trunk' into add/admin-script-style-preloading
westonruter cf6e2a6
Rename the prefetch_admin_assets filter to wp_prefetch_admin_assets
westonruter ebba75b
Use the HTML Tag Processor to find the login footer's jQuery script a…
westonruter 2a5c724
Type the as value of the prefetch test helpers as 'script'|'style'
westonruter e514355
Test that an escaped copy of a prefetched URL is collapsed with it
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These (and
WP_Styles::get_src()/get_rtl_src()) would be the first public methods onWP_Scripts/WP_Styleswith parameter and return types. A subclass that already defines an untypedget_src( $handle )will fatal with "Declaration ... must be compatible". I haven't checked whether any plugin does that; worth a WPdirectory search, or dropping the types to match the rest of both classes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Comment by Claude Opus 5.5
The plugin directory was searched (via Veloria) for both halves of the risk:
extends WP_Scripts/extends WP_Styles: 29 matches across 19 plugins, such as Jetpack Boost, Page Optimize, PWA and Powered Cache.function get_src(,function get_rtl_src(orfunction build_src(: 62 matches across 44 plugins, such as Yoast SEO, Beaver Builder and Timber.No plugin appears in both sets. The
get_src()matches are on unrelated classes, so no subclass ofWP_ScriptsorWP_Stylesin the directory defines any of these methods. All four methods are new in this PR, so no subclass can have overridden them before. A collision would need a private subclass that happened to use the same name, and such a method would most likely conflict in meaning even without the types. On that basis the native types are being kept. They can be dropped if the risk outside the directory is considered too high.