#57548 closed enhancement (fixed)
Stop concatenating scripts and stylesheets in wp-admin and retire load-scripts.php and load-styles.php
| Reported by: | azaozz | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Script Loader | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | performance |
Description
This functionality was added 14 years ago, #8628. At the time it made the loading of wp-admin quite faster by reducing the number of HTTP requests by more than 50%. The downside is that each wp-admin page has it's own set of concatenated scripts and stylesheets making them harder for caching in browser/network caches. Nevertheless the benefits of the reduced number of requests was greater than the insufficient caching.
This changed when HTTP/2 became more popular. Scripts and stylesheets are loaded much more efficiently there and concatenation is generally not needed. This allows for better browser/network caching and for eventual prioritization. In that terms disabling concatenation of scripts and stylesheets in wp-admin would reduce complexity and improve performance in many cases.
Change History (68)
#2
@
4 years ago
I think this is worth pursuing. Once we have a working solution, we should gather some performance comparisons to make a comparison between the two approaches.
This ticket was mentioned in Slack in #core-editor by mamaduka. View the logs.
3 years ago
#4
follow-up:
↓ 8
@
3 years ago
The current implementation (in WordPress 6.3) is currently causing the asset generation and concatenation to fail with an HTTP 503 error if less than 1.5 Gb RAM is assigned to the site. See https://github.com/WordPress/gutenberg/issues/54294 for fuller details.
This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.
3 years ago
#8
in reply to: ↑ 4
@
15 months ago
Replying to markhowellsmead:
The current implementation (in WordPress 6.3) is currently causing the asset generation and concatenation to fail with an HTTP 503 error if less than 1.5 Gb RAM is assigned to the site. See https://github.com/WordPress/gutenberg/issues/54294 for fuller details.
#47322 is a ticket with a simple patch that likely reduces peak memory usage for wp-admin/load-styles.php.
#9
@
15 months ago
My understanding is that there are still benefits from concatenation with HTTP/2, particularly on servers configured with compression.
While it is true that assets can be downloaded in parallel, each file will have it's own compression dictionary. For example, each CSS file will have entries for color, background, font, font-size, etc.
By concatenating the requests WordPress is reducing the number of dictionaries that need to be transferred across the wire. Harry Roberts documents the results in a post on HTTP performance.
Rather than rely on instinct, it would be good to get some data on the benefits for common screens: the dashboard, the post list, the post editor.
As WP is all-or-nothing at the moment with concatenation, another comparison point is to check limiting the number of script in a single concatenated request to N files.
#10
follow-up:
↓ 11
@
15 months ago
@peterwilsoncc We should test this indeed.
You're referring to transferring dictionaries, but Compression Dictionaries aren't implemented by load-scripts.php, right? Also, I don't see that there is even any compression at all (e.g. GZip). Maybe I'm not seeing something.
The additional latency required to boot up PHP to concatenate the scripts should be considered as well. Serving static files would be a much faster TTFB.
We can get some additional benefits by preloading key scripts and styles used on in the editor when the user lands on the dashboard, for example.
#11
in reply to: ↑ 10
@
15 months ago
Replying to westonruter:
@peterwilsoncc We should test this indeed.
You're referring to transferring dictionaries, but Compression Dictionaries aren't implemented by
load-scripts.php, right? Also, I don't see that there is even any compression at all (e.g. GZip). Maybe I'm not seeing something.
Yes, that's what I'm referring to.
WordPress doesn't do anything, I'm thinking of the compression modules used by web servers & CDNs.
On the two sites I can readily use live servers to run experiments with, adding define( 'CONCATENATE_SCRIPTS', true ); increased the transfer size of the CSS while the JS dropped a little.
#12
@
15 months ago
I shared this ticket with some trusted performance folks @sergiomdgomes and @josephscott, I'll summarize their feedback here.
Most results seem to indicate that concatenation remains beneficial in general. It hasn't been made obsolete by HTTP/2.
A few additional links discussing the topic:
There's also "tight mode" discussed in this talk around 11 minutes:
Chrome loads resources in 2 phases. “Tight mode” is the initial phase and constrains loading lower-priority resources until the body is attached to the document (essentially, after all blocking scripts in the head have been executed). In tight mode, low priority resources are only loaded if there are less than 2 in-flight requests at the time that they are discovered.
It seems conclusive that concatenation is usually better for performance. Does anyone have evidence to the contrary?
To move this forward, a different case needs to be made because it doesn't seem like "no performance benefit from concatenation" is valid.
Do the benefits of not concatenating outweigs the drawbacks of degraded performance. Or in the contexts where concatenation is used (like the customizer view) is degraded performance irrelevant? Or is concatenation so buggy that it doesn't make sense to support it?
#13
@
15 months ago
- Focuses performance added
Thank you, @jonsurrell!
Sorry for not joining the discussion earlier, but I'd like to add a few comments inline now that I'm here :)
Browser module loading - can we stop bundling yet?
I just wanted to add a note that my article is really old, and most of the findings may no longer apply. Still, it mentions the sort of issues one can reasonably expect.
In general, I haven't seen conclusive evidence that concatenation no longer has a benefit.
As @peterwilsoncc mentions, the "small files" compression problem is still relevant, and there isn't a cross-browser solution to address it. Even though WordPress doesn't handle compression itself (whether gzip or brotli), the expectation is that a competent host will enable it at the HTTP server level, and that it will have a meaningful impact on performance, so it's something we do need to consider.
The additional latency required to boot up PHP to concatenate the scripts should be considered as well. Serving static files would be a much faster TTFB.
This would be good to test, but we have to remember that the WordPress ecosystem is extremely heterogenous, and it's difficult to make broad assertions that are valid everywhere.
In this case, since we're thinking outside of WordPress and at the level of serving infrastructure, we have to consider the impact of edge caches as well. It's reasonable to assume that the concatenated files would also be edge cached, potentially negating the effect of any boot-up cost in concatenation at scale.
We can get some additional benefits by preloading key scripts and styles used on in the editor when the user lands on the dashboard, for example.
Preloading is a rather forceful technique that should be used with extreme caution, as it has the potential to make things worse. It's generally preferable to leave prioritisation to the browser, and at most provide hints in the form of fetchpriority or by rearranging things so that the resource is discovered earlier.
In any case, if there is any benefit to be had here, it may be worth exploring independently of concatenation.
Don't get me wrong, there are definitely some downsides to concatenation. Beyond the security issues mentioned, it makes debugging harder, and it can worsen problems with scripts, in that script-breaking bugs now break all the concatenated scripts, not just the one script.
But in terms of performance, the evidence I've seen so far is that there's still an improvement.
This ticket was mentioned in Slack in #core by welcher. View the logs.
14 months ago
#15
@
14 months ago
- Milestone 6.9 → Future Release
With 6.9 beta 1 happening in ~2 weeks and this ticket still be discussed, I am going to move this to Future Release.
#16
@
13 months ago
Related: #58302 (Deprecate and disable the unused compression_test() and wp_ajax_wp_compression_test())
This ticket was mentioned in Slack in #core-performance by westonruter. View the logs.
11 months ago
This ticket was mentioned in Slack in #core-performance by westonruter. View the logs.
11 months ago
#20
@
10 months ago
- Milestone 7.0 → Future Release
- Owner set to
- Status new → accepted
I haven't gotten around to this, so I'm punting given we're a couple weeks from beta1. But I'm self-assigning as a reminder to investigate.
#21
@
9 months ago
Coming in from #64087 as the ghost of WordPress past.
Here's a good reason to get rid of this system: It's riddled with PHP warnings that have been intentionally suppressed.
At the top of load-styles.php and load-scripts.php is the following code:
/*
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
* it's best to add a dummy function to the wp-config.php file, but as this call to the function
* is run prior to wp-config.php loading, it is wrapped in a function_exists() check.
*/
if ( function_exists( 'error_reporting' ) ) {
/*
* Disable error reporting.
*
* Set this to error_reporting( -1 ) for debugging.
*/
error_reporting( 0 );
}
It's there because without it, any call to load-styles.php will generate multiple warnings, especially because the noop.php zeroes out all filters to return null, which triggers PHP8 warnings for things like file_exists() that don't accept null. Thanks to @westonruter for helping me figure that part out.
I stumbled on to this weird detail because on our live server we have an alternate error handler that doesn't respect error_reporting() and effectively always runs in E_ALL, so the warnings were being triggered after we updated to PHP 8.
As I said in the other ticket, the particular warnings I noticed don't even seem worth fixing, because the whole system assumes there are warnings/errors and intentionally ignores them.
If there's no great argument to keep this system, I vote to nuke it from space. I've been running in define( 'CONCATENATE_SCRIPTS', false ); mode for months now and it works fine and resolves all the warnings.
This ticket was mentioned in PR #11577 on WordPress/wordpress-develop by @sukhendu2002.
7 months ago
#22
- Keywords has-patch has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/57548
## Use of AI Tools
#23
@
5 months ago
- Milestone Future Release → 7.1
Another issue has been raised regarding this: #65515.
When a script is in strict mode (where "use strict" appears at the beginning of the script), and this script is the first to get concatenated, then all remaining concatenated scripts are put into strict mode. This causes errors in ThickBox and potentially other scripts.
Conversely, if we worked around this and forced the concatenated script to be in "sloppy mode", then this can cause other errors because there are semantic differences, as pointed out by @siliconforks.
I think the only reasonable way out of all this is to deprecate and remove concatenation. We can use an alternate strategy for improving performance, such as preloading the individual scripts and styles. By preloading individual assets, they'll be better cached given that they'll be outside of the current concatenation bundles.
This ticket was mentioned in Slack in #meta by westonruter. View the logs.
5 months ago
#26
@
4 months ago
- Milestone 7.1 → 7.2
Punting this because we have a workaround for the most recent issue identified above.
For this to move forward, we need to not only remove the concatenation logic but also add the appropriate preload links (e.g. from the login screen) so that when a user lands on the dashboard and post editor they'll have a primed cache.
@westonruter commented on PR #11577:
3 months ago
#28
Thanks for the PR, but before getting to implementation, we'll need to do more discovery.
Also, the PR description is missing details about what is included.
This ticket was mentioned in PR #13084 on WordPress/wordpress-develop by @westonruter.
3 months ago
#29
Explores one way to soften the cost of retiring script and style concatenation, per Core-57548: warm the admin's assets from the login screen so the first admin page load after signing in does not pay for them.
## Why
Benchmarking the Dashboard on a throttled Fast 4G connection, 10 runs per condition, medians:
| Metric | Concat on | Concat off | Δ |
| --- | ---: | ---: | ---: |
| Cache disabled — FCP | 740 ms | 1342 ms | +602 ms (+81%) |
| Cache disabled — LCP | 744 ms | 1342 ms | +598 ms (+80%) |
| Cache disabled — Load | 3574 ms | 4322 ms | +748 ms (+21%) |
| Cache enabled — FCP | 326 ms | 328 ms | +2 ms |
| Cache enabled — LCP | 326 ms | 328 ms | +2 ms |
| Cache enabled — Load | 347 ms | 352 ms | +5 ms |
Requests went from 95 to 123 with concatenation off; transferred bytes actually went *down* slightly, from 1557 KB to 1488 KB.
Two things stand out. Once the cache is warm the difference disappears entirely — the run-to-run spread swallows it. And the cold-cache gap is dominated by request serialization rather than bytes: this was measured over HTTP/1.1, where the six-connection-per-origin cap turns the 28 extra requests into roughly twenty round trips at 85 ms each, which is close to the 600 ms observed. That figure should shrink substantially over HTTP/2, so it is best read as an upper bound on what concatenation is worth.
That leaves the cold first admin load as the case worth addressing, and the login screen is a natural place to address it: the user is sitting on it typing credentials, the connection is idle, and the next navigation is almost always into the admin.
## What this does
Prints <link rel="preload" … fetchpriority="low"> tags on the login screen for the handles that load-scripts.php and load-styles.php would have bundled — 6 scripts and 25 styles — so they land in the HTTP cache before the redirect. fetchpriority="low" keeps them queued behind the login screen's own render-blocking assets. Handles the login screen has already printed itself are skipped, which drops 6 of the 31 in a default install.
Nothing is printed when concatenation is enabled, since load-scripts.php and load-styles.php already collapse these handles into a handful of requests.
Two additions in src/wp-includes/script-loader.php:
wp_preload_admin_assets()— builds and prints the list, hooked tologin_headat priority 10 (just afterprint_admin_styles). Exposes alogin_preload_admin_assetsfilter taking the same resource shape aswp_preload_resources, so the set can be adjusted or emptied._wp_resolve_dependency_urls()— private helper resolving a registered handle to the URL it would load from, mirroringWP_Scripts::do_item()andWP_Styles::do_item(): the version argument, thescript_loader_srcandstyle_loader_srcfilters, and the RTL replace-or-append rules. It prints nothing and does not touch the queue.
## A pre-existing quirk this ran into
The obvious gate, the $concatenate_scripts global, does not work on the login screen. script_concat_settings() usually runs on a login request *before* login_init fires — registering any script on init is enough to trigger it — and at that point it evaluates is_admin() as false, so the global settles on false no matter what CONCATENATE_SCRIPTS says. A side effect is that the login screen itself never concatenates even with the constant on, which is easy to confirm by loading wp-login.php and looking for load-styles.php.
This patch therefore gates on CONCATENATE_SCRIPTS && ! SCRIPT_DEBUG, which is what script_concat_settings() would compute for the admin request the login leads to. The underlying quirk looks worth a ticket of its own and is untouched here.
## Testing instructions
- Ensure
CONCATENATE_SCRIPTSisfalseandSCRIPT_DEBUGisfalse. - Log out and load
wp-login.php. View source: there should be 25<link rel="preload" … fetchpriority="low">tags. - Set
CONCATENATE_SCRIPTStotrueand reload. There should be none. - Set
SCRIPT_DEBUGtotruewithCONCATENATE_SCRIPTSstilltrueand reload. The tags return, since the admin will not concatenate either. - With concatenation off, log in and compare the preloaded URLs against what the Dashboard requests — every one should match and be served from cache.
Verified against 7.2-alpha-63166-src: all 25 preloads were fetched on the login screen, all 25 matched a Dashboard request exactly, and all 25 were served from cache with transferSize 0. No "preloaded but not used" console warnings appeared. PHPCS is clean and PHPStan reports no errors on the changed lines.
## Open questions
- No automated tests yet. Happy to add coverage for the gate and for
_wp_resolve_dependency_urls(), including the RTL branches, if the approach seems worth pursuing. - The handle list is hardcoded. Deriving it would mean resolving the admin's enqueue queue from the login screen, which is not practical. A fixed list is easy to review but will drift as core's default enqueues change.
rel="preload"versusrel="prefetch". These resources are for the *next* navigation, which is whatprefetchdescribes;preloadwithfetchpriority="low"was chosen for its more reliable cache behaviour across browsers. No unused-preload warnings were observed, but the semantics are worth a second opinion.- Scope. Concatenation covered only 31 of the Dashboard's 123 requests, so this recovers part of the gap rather than all of it. It has not been re-benchmarked yet.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Running the benchmark and statistics, drafting the implementation, and drafting this description. The approach, the decision to gate on the constants, and the final code were reviewed and edited by me.
@manzoorwani.jk commented on PR #13084:
3 months ago
#30
Claude Code analysis of the change
# wp-admin script/style concatenation: phase 1 findings (HTTP/1.1, /wp-admin/ Dashboard)
Measured on 2026-08-16 against the local Docker env (nginx:alpine, HTTP/1.1, LOCAL_DIR=build, minified assets, SCRIPT_DEBUG=false) with the Chrome DevTools MCP server.
## Summary
- Cold loads (cache bypassed) on a throttled connection are where concatenation matters: removing it makes Dashboard FCP/LCP go from 616 ms to 1304 ms with gzip on (+688 ms, +112%) and from 1296 ms to 1484 ms with gzip off (+188 ms, +15%).
- With a primed browser cache the difference is noise: +12 ms (+5%) with gzip on, within a few ms with gzip off.
- Unthrottled on localhost, concat off is marginally faster (160 ms vs 172 ms), i.e. the PHP cost of
load-styles.php/load-scripts.phpoutweighs the request savings when latency is near zero. - The whole effect comes from CSS: concat collapses 26 render-blocking stylesheets into one
load-styles.phprequest. Scripts are barely concatenated on the Dashboard (only 6 handles in 2load-scripts.phpbundles; the other ~80 scripts load individually in both modes because they carry inline data or translations). - FCP and LCP were identical (or within 30 ms) in every run; the LCP element is the "Welcome" H2 heading, so both metrics are gated by render-blocking CSS.
## Results
Fast 4G is Chrome DevTools' built-in preset applied via CDP Network.emulateNetworkConditions. N = 10 recorded runs per cell after 2 unrecorded warm-ups. IQR is p25 to p75.
| Throttle | gzip | Cache | Concat | N | Median FCP (ms) | FCP IQR | Median LCP (ms) | LCP IQR | Requests | Transfer |
|---|---|---|---|---|---|---|---|---|---|---|
| Fast 4G | on | bypassed | on | 10 | 616 | 612 to 619 | 616 | 612 to 619 | 89 | 1354 KB |
| Fast 4G | on | bypassed | off | 10 | 1304 | 1300 to 1307 | 1304 | 1300 to 1307 | 117 | 1375 KB |
| Fast 4G | on | primed | on | 10 | 252 | 248 to 260 | 252 | 248 to 260 | 90 | 1 KB |
| Fast 4G | on | primed | off | 10 | 264 | 261 to 264 | 264 | 261 to 264 | 118 | 1 KB |
| Fast 4G | off | bypassed | on | 10 | 1296 | 1293 to 1296 | 1296 | 1293 to 1296 | 89 | 4360 KB |
| Fast 4G | off | bypassed | off | 10 | 1484 | 1481 to 1487 | 1484 | 1481 to 1487 | 117 | 4369 KB |
| Fast 4G | off | primed | on | 10 | 260 | 256 to 260 | 276 | 273 to 280 | 90 | 3 KB |
| Fast 4G | off | primed | off | 10 | 256 | 256 to 260 | 282 | 280 to 284 | 118 | 3 KB |
| None | on | bypassed | on | 10 | 172 | 172 to 175 | 172 | 172 to 175 | 89 | 1354 KB |
| None | on | bypassed | off | 10 | 160 | 153 to 163 | 160 | 153 to 163 | 117 | 1375 KB |
Delta of "concat off" versus "concat on" (positive = removing concat is slower):
| Throttle | gzip | Cache | FCP on | FCP off | Delta ms | Delta % | LCP on | LCP off | Delta ms | Delta % |
|---|---|---|---|---|---|---|---|---|---|---|
| Fast 4G | on | bypassed | 616 | 1304 | +688 | +112% | 616 | 1304 | +688 | +112% |
| Fast 4G | on | primed | 252 | 264 | +12 | +5% | 252 | 264 | +12 | +5% |
| Fast 4G | off | bypassed | 1296 | 1484 | +188 | +15% | 1296 | 1484 | +188 | +15% |
| Fast 4G | off | primed | 260 | 256 | -4 | -2% | 276 | 282 | +6 | +2% |
| None | on | bypassed | 172 | 160 | -12 | -7% | 172 | 160 | -12 | -7% |
Request shape per condition (from the network log):
- Concat on: 3 stylesheet requests (1
load-styles.phpbundling 26 handles,thickbox.css,colors.min.css) pluseditor.min.css, and 2load-scripts.phpbundles (jquery-core,jquery-migrate,utilsandhoverIntent,wp-dom-ready,wp-hooks) plus ~80 individual scripts. - Concat off: 28 stylesheet requests and 84 script requests, all individual files.
- Transferred bytes are essentially the same in both modes (1354 vs 1375 KB gzipped, 4360 vs 4369 KB raw); the difference is request count and HTTP/1.1 connection queuing, not payload.
## Raw per-run values (ms)
- Fast 4G, gzip on, bypassed, concat on: FCP 620, 612, 612, 616, 624, 616, 612, 616, 620, 612; LCP same as FCP
- Fast 4G, gzip on, bypassed, concat off: FCP 1304, 1296, 1304, 1300, 1308, 1312, 1300, 1300, 1304, 1308; LCP same as FCP
- Fast 4G, gzip on, primed, concat on: FCP 248, 260, 248, 260, 252, 268, 340, 252, 244, 248; LCP same as FCP
- Fast 4G, gzip on, primed, concat off: FCP 264, 252, 264, 264, 268, 264, 264, 260, 264, 256; LCP same as FCP
- Fast 4G, gzip off, bypassed, concat on: FCP 1296, 1296, 1288, 1296, 1292, 1300, 1292, 1296, 1300, 1296; LCP same as FCP
- Fast 4G, gzip off, bypassed, concat off: FCP 1484, 1484, 1488, 1480, 1484, 1480, 1476, 1484, 1488, 1488; LCP same as FCP
- Fast 4G, gzip off, primed, concat on: FCP 260, 264, 260, 256, 256, 260, 256, 260, 260, 256; LCP 276, 280, 284, 272, 272, 276, 280, 276, 288, 272
- Fast 4G, gzip off, primed, concat off: FCP 256, 260, 264, 256, 260, 256, 252, 256, 260, 256; LCP 272, 284, 280, 280, 284, 284, 280, 284, 284, 280
- Unthrottled, gzip on, bypassed, concat on: FCP 172, 168, 168, 176, 172, 172, 176, 172, 172, 196; LCP same as FCP
- Unthrottled, gzip on, bypassed, concat off: FCP 164, 164, 152, 160, 156, 160, 160, 148, 152, 164; LCP same as FCP
## Method
- Fixture: trunk at
3150f656e2(includes the gzip toggle from PR #12529),npm run build,.envwithLOCAL_DIR=buildandLOCAL_NGINX_COMPRESSION=on|off, env restarted on every gzip switch and verified withcurl -I(Content-Encoding: gzippresent or absent). - Toggle:
wp-config.phpdefinesSCRIPT_DEBUGandCONCATENATE_SCRIPTSfrom$_GET['script_debug']/$_GET['enable_concat'](exacttrue/falsestrings; defaults false/true), setsWP_DEBUG_DISPLAYfalse andDISABLE_WP_CRONtrue. URLs measured:/wp-admin/?enable_concat=true&script_debug=falseand/wp-admin/?enable_concat=false&script_debug=false. - Static asset caching: the local nginx template got a
location ~* \.(js|css)$ { expires 1y; add_header Cache-Control "public"; }block so individual assets are cacheable like on production hosts (otherwise the primed comparison is unfairly tilted towardload-*.php, which sends its own 1 year max-age). - Browser: dedicated isolated Chrome context, logged in as
admin, viewport 1440x900, no extensions, tab in foreground, no interaction during loads. - Cache bypassed: CDP hard reload (
Page.reloadwithignoreCache), which refetches every subresource (verified: 114 of 117 resources with non-zero transferSize each run). Primed: one priming load, then soft reloads; verified all subresources served from cache (transferSize 0). - Metrics: read in-page after
load+ 1.5 s settle viaperformance.getEntriesByName('first-contentful-paint')and a bufferedlargest-contentful-paintPerformanceObserver (last entry), recorded per run, median and IQR computed offline. Raw JSON per cell is in the session scratchpadresults/folder. - Preflight per condition confirmed the presence/absence of
load-scripts.php/load-styles.php, request counts,.minassets andContent-Encoding.
## Caveats
- Run-to-run spread is tiny (IQR 3 to 8 ms) because DevTools throttling is a deterministic simulation on top of a localhost server. Real networks will be noisier; the direction and magnitude of the cold-load penalty on HTTP/1.1 is what to take from this, not the exact ms.
- "Cache bypassed" reuses warm TCP connections across reloads and is a repeated-navigation scenario, not a true first visit (no DNS/TCP handshake cost is included). A real first visit would make the concat-off penalty on HTTP/1.1 slightly larger.
- Only the Dashboard was measured. Screens with larger CSS/JS bundles (post editor: 36 style handles, customizer) will show a bigger cold-load gap.
- Chrome's Fast 4G preset values are what the current Chrome build ships; the observed document TTFB under throttling was ~100 ms.
## Interpretation for the removal decision
- Removing concatenation with no replacement is a clear regression for cold loads on HTTP/1.1: roughly 2x FCP/LCP on the Dashboard with gzip, ~15% without gzip. Returning visitors with a warm cache are unaffected.
- The regression is entirely about the number of render-blocking CSS requests. Any replacement only needs to address CSS delivery on first load (fewer stylesheet requests,
preload, or103 Early Hints); the script side is already effectively unconcatenated on this screen. - HTTP/2 and HTTP/3 (phase 2) should shrink this gap substantially since request multiplexing removes the 6-connection HTTP/1.1 limit; that measurement is the next step before deciding.
## Environment state left in place (revert notes)
These local changes are still applied so phase 2 can continue; none are committed:
-
.env:LOCAL_DIR=build,LOCAL_NGINX_COMPRESSION=on(wassrc, unset). Revert andnpm run env:restartto get back to the normal dev setup. -
wp-config.php:SCRIPT_DEBUG/CONCATENATE_SCRIPTSquery toggles,WP_DEBUG_DISPLAYfalse,DISABLE_WP_CRONtrue (wasSCRIPT_DEBUGtrue,WP_DEBUG_DISPLAYtrue). -
tools/local-env/default.template: theexpires 1yblock for.js/.css(shows ingit diff). -
concat-perf-strategy.mdand this file are untracked in the repo root.
@manzoorwani.jk commented on PR #13084:
3 months ago
#31
Combined review of Claude and Codex
# Review of PR #13084: Preload the admin's unconcatenated assets from the login screen
Reviewed against concat-perf-findings.md and concat-perf-strategy.md (HTTP/1.1, Dashboard, Fast 4G, local Docker env, LOCAL_DIR=build, gzip on). The PR branch was checked out and its two PHP files were copied into build/ for testing; the copies were reverted afterwards. Codex reviewed the same diff independently; its findings are folded in and attributed below.
## Verdict
The mechanism works as described and the measured effect on the first Dashboard load after login is large. It is not a general answer to removing concatenation: it only helps a cold cache that happens to pass through wp-login.php, uses rel="preload" for a next-navigation resource (which Chrome does warn about, contrary to the PR description), and pushes 25 speculative requests onto every login-family screen. Worth continuing as a complementary optimization if the handle list is derived rather than hardcoded and the semantics are switched to prefetch, but it should not be the argument for retiring load-styles.php.
## What was verified
- Handle lists match exactly what concatenation produces on the Dashboard today: the 25 style handles are the two
load-styles.phpchunks (wp-pointeris split across the chunk boundary, which is why the findings doc counted 26) and the 6 script handles are the twoload-scripts.phpbundles. - With
CONCATENATE_SCRIPTS=false,SCRIPT_DEBUG=false: 25<link rel='preload'>tags after the 7 login stylesheets, none with concat on. All 25 URLs match Dashboard request URLs byte for byte, and after login all 31 preloaded assets (including the 6 shared with login) are served withtransferSize0. - Effect on the first Dashboard load after login, Fast 4G, cold cache, concat off: FCP 1128 ms (trunk) vs 572 ms (PR). For reference the findings doc has concat on at 616 ms and concat off at 1304 ms on a hard reload, so the PR recovers the whole FCP gap for this one path.
loadwent 3738 ms to 3052 ms; 41 vs 20 of 118 resources from cache. - Cost on the login screen itself, Fast 4G, cold cache: FCP 572 ms (trunk) vs 580 ms (PR), so render is not hurt.
loadevent moved from 900 ms to 1475 ms and resource count 23 to 44. Extra transfer is 129 KB gzipped (557 KB raw), about 2.6x the login page's own CSS payload. - Chrome logs 21 "was preloaded using link preload but not used within a few seconds from the window's load event" warnings on the login screen (every preload except
jquery-core,jquery-migrate,wp-dom-ready,wp-hooks, which the login page consumes itself). The PR description says no such warnings appeared; that is not what a default install shows.
## Findings
### Design
- Scope of the win is narrow. It only helps a cold cache reached via
wp-login.php. Cold-cache admin loads that never see the login screen are common and arguably more common for logged-in users: every core update changes everyverstring, plugin updates change theirs, and remember-me cookies last 14 days. Those paths still pay the full concat-off penalty from the findings doc (+688 ms FCP on HTTP/1.1 with gzip). The PR should be framed as a complement, not a replacement. preloadvsprefetch. The resources are for the next navigation, which is whatprefetchmeans. Consequences of usingpreloadhere: unused-preload console warnings on every login page load (verified), preload priority semantics rather than idle-time semantics, and cross-navigation reuse depends entirely on the static files' HTTP cache headers, which core does not control. On hosts with noCache-Control/Expireson.css/.js, freshly deployed files get short heuristic freshness and the Dashboard will revalidate each one (304 per file, still one HTTP/1.1 round trip each). Chrome keepsprefetchresponses reusable for 5 minutes regardless of cacheability, which fits this use case better. This needs a browser-by-browser check either way (Codex raises the same point).- Runs on every
login_head, not just the login form:lostpassword,resetpass,register, logout confirmation,interim-login, failed logins. Speculatively fetching 129 KB gzipped for a user who lands on "check your email" is wasted, andSave-Datais not honored (Codex). - Scripts are not worth preloading. Both the findings doc and the PR's own numbers show the gap is CSS. Dropping the 6 script handles removes the custom script URL resolver (and finding 6 below) for negligible loss.
- Hardcoded list will drift. Nothing ties it to what
WP_Styles::do_item()actually concatenates.site-healthis capability-gated on the Dashboard,admin-barcan be disabled,wp-auth-checkcan be filtered off (Codex). A more robust shape: register the list next to thewp-adminalias inwp_default_styles(), or derive it from thewp-adminhandle's dependency tree plus a small explicit set, and add a test that compares it against the concat output on the Dashboard. - Locale mismatch. The login screen resolves URLs with the site (or
wp_lang) locale; the admin uses the user locale. An RTL user on an LTR site preloads the LTR files and then loads the RTL ones. Edge case, but it is silent waste.
### Correctness in _wp_resolve_dependency_urls()
- Script branch drops
$dependencies->args[ $handle ]and the#fragmenthandling thatWP_Scripts::do_item()has (class-wp-scripts.php around the$added_argsblock). No core handle in the list uses either, but the helper claims to mirrordo_item()and a plugin passinghandle?argwould preload a URL that never gets requested. Goes away if scripts are dropped (finding 4). script_loader_src/style_loader_srcrun in a logged-out, non-admin request. Filters that branch onis_admin(), screen or user (CDN rewriters, per-user asset URLs) can produce a URL that differs from the one the admin request will load, defeating the cache hit. Also 31 extra filter invocations on an unauthenticated page (Codex). Worth a sentence in the docblock at least.- Gate:
script_concat_settings()honors a pre-set$concatenate_scriptsglobal and plugins can defineCONCATENATE_SCRIPTSonly whenis_admin(); the constant-only prediction can be wrong in both directions (Codex). Acceptable given the login-screen quirk the PR describes, but the docblock should say the gate is a prediction. - Double escaping is harmless:
_css_href()already returnsesc_url()output andesc_url()is idempotent (verified), but the RTL branch string-replaces on an escaped URL exactly likedo_item()does, so it is at least consistent. - Filter contract: the docblock says the
login_preload_admin_assetsfilter takes the same shape aswp_preload_resources, but the printer only emitshref,as,fetchpriority;crossorigin,type,mediaare dropped (Codex). Either print the same attribute set aswp_preload_resources()or narrow the docblock. - Not idempotent: calling
wp_preload_admin_assets()twice prints the tags twice (Codex). Minor.
### Verified as fine
- Hook priority 10 after
print_admin_styles/wp_print_head_scriptsat 9, so thedonecheck correctly skips the 6 login-shared handles. - RTL replace/append logic matches
WP_Styles::do_item(); core admin styles all usereplacewith a suffix. - Escaping of filtered output (
esc_url,esc_attr, type checks) is fine. - Login FCP is not regressed by the extra requests on Chrome with
fetchpriority="low"(measured +8 ms).
## Suggested direction
- Keep the idea, switch to
rel="prefetch"(or measure both across Chrome, Firefox, Safari with and without static cache headers before deciding). - Styles only; drop the script preloads and the script resolver.
- Restrict to the login form action, skip
Save-Data, skipinterim-login. - Derive the handle list or add a test that fails when it drifts from the Dashboard concat output.
- Re-benchmark the login screen on Fast 3G / mobile, since the cost is bandwidth rather than render.
- Do not use this as the basis for removing concatenation; the phase 2 HTTP/2 and HTTP/3 measurement in the strategy doc is still the missing input.
## Codex review (verbatim summary of its verdict)
"Overall verdict: not a sound approach. The URL resolver has fixable correctness gaps, but the larger problem is architectural: preload is being used for a future navigation and forces a sizable speculative download on every login-family screen. A CSS-only concatenation strategy, or admin-response Early Hints where supported, is substantially safer."
Where I differ from Codex: it rated the login-screen cost as blocking; measured, login FCP is unaffected and the cost is bandwidth plus a later load event, so I would rate it important rather than blocking. Its wp_installing() point does not apply (the login screen is not shown during install). Its architectural point stands. Full Codex output: session 01a00c8d-755c-7f70-bd92-98cecb0b185c (codex resume 01a00c8d-755c-7f70-bd92-98cecb0b185c).
@Adnan007 commented on PR #13084:
3 months ago
#32
@westonruter commented on PR #13084:
3 months ago
#33
🤖 _Claude analysis of benefit of preloading_
## Dashboard load after logging in (10 runs per arm, fresh cache each run)
| Metric | No preload (control) | With preload | Δ |
| ----------------- | -------------------: | -----------: | -----------------: |
| FCP | 1256 ms | 714 ms | −542 ms (−43%) |
| LCP | 1256 ms | 714 ms | −542 ms (−43%) |
| DOMContentLoaded | 3880 ms | 3252 ms | −628 ms (−16%) |
| Load event | 4096 ms | 3466 ms | −630 ms (−15%) |
| Login POST + 302 | 291 ms | 293 ms | +2 ms |
| Requests | 123 | 123 | 0 |
| Served from cache | 21 | 42 | +21 |
| Transferred | 1366.9 KB | 1271.9 KB | −95.0 KB |
Distributions don't overlap at all — 1244–1280 ms vs 688–728 ms.
That's 542 of the original 602 ms concat-on/off FCP gap, or 90%.
Subtracting the login POST + redirect (~292 ms, present in both arms) to compare against the earlier direct-navigation numbers:
| Scenario | FCP |
| ----------------------------------------- | ---------: |
| Concat ON, cold, direct nav *(earlier)* | 740 ms |
| Concat OFF + preload, redirect-adjusted | 421 ms |
| Concat OFF, no preload, redirect-adjusted | 965 ms |
| Concat OFF, cold, direct nav *(earlier)* | 1342 ms |
Preloading doesn't just close the gap — it beats concatenation, because the bytes move during idle time on the login screen instead of during the dashboard load.
## Cost to the login screen
| Metric | No preload | With preload | Δ |
| --------------------- | ---------: | -----------: | ----------: |
| Login FCP | 570 ms | 568 ms | −2 ms |
| Login load event | 908 ms | 1597 ms | +689 ms |
| Last preload finished | — | 1570 ms | — |
fetchpriority="low" is doing its job: the login screen's own paint is untouched. What does move is the load event, +689 ms, because it waits on the preloads. Worth knowing if anything hooks window.onload there.
## Two caveats on reading this
Why I ran a control arm despite you saying not to re-test. The earlier cold-cache number (1342 ms) was a hard reload of the dashboard, not a login→dashboard navigation. Going through the login screen warms 21 shared assets by itself, so that flow lands at 965 ms even with zero preloads. Without the control, preloading would have looked like it recovered 628 ms when the honest figure is 542 ms.
Dwell time. Preloads finish at ~1570 ms; the runs used a fixed 4-second dwell on the login screen, identical in both arms. A user whose password manager submits in under ~1.6 s gets proportionally less. Everything is still HTTP/1.1, so the whole effect should shrink over HTTP/2.
This ticket was mentioned in PR #13090 on WordPress/wordpress-develop by @Adnan007.
3 months ago
#34
Flips the fallback in script_concat_settings() so an undefined CONCATENATE_SCRIPTS resolves to false instead of true. load-scripts.php and load-styles.php become opt-in — sites that want the current behaviour can define( 'CONCATENATE_SCRIPTS', true ).
Scope is narrower than the constant's name suggests. The guard immediately below already forces the global to false outside of is_admin() and login_init, so only wp-admin and the login screen change. The concatenation code paths themselves are untouched.
Two reasons to make this the default:
- Concatenation is the root of a class of bugs that only appear when it is on.
SCRIPT_DEBUGbeing ignored (#52879), translations not printing for concatenated handles (#50999), and"use strict"leaking between bundled scripts (#65515) are all conditions a stock install currently ships into. Defaulting off takes wp-admin off that path. - It is what makes #13084 do anything. That PR warms the admin's individual assets from the login screen, but gates on concatenation being off. Under today's default it is inert on a stock install; with this flip it applies by default, which is the pairing the two changes were intended to have.
The cold-cache performance trade-off is the open question here, and the benchmark numbers and the compression-dictionary discussion belong on the ticket rather than in this diff. Opening as a draft for that reason.
## Testing instructions
- Use an install with neither
CONCATENATE_SCRIPTSnorSCRIPT_DEBUGdefined inwp-config.php. - Load any wp-admin screen (the Dashboard is fine) and view source. There should be no requests to
load-scripts.phporload-styles.php— every handle appears as its own<script src>or<link href>. - Confirm the admin behaves normally: menus, the list tables, and the block editor should all load without console errors.
- Add
define( 'CONCATENATE_SCRIPTS', true );towp-config.phpand reload the same screen. Bothload-scripts.phpandload-styles.phpshould reappear, confirming the opt-in path still works. - Load the front end in both configurations. It should be unaffected either way, since concatenation was already forced off outside the admin.
PHPUnit was run in full against this branch: 30,865 tests, 4,558,964 assertions, 3 failures. All three reproduce on the unmodified baseline — two WP_Automatic_Updater open_basedir tests that end their child process unexpectedly in this environment, and test_default_script_module_files_exist, which needs built assets that were not present in the checkout. PHPCS reports no issues on the changed file.
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Making the change, running the test suite and confirming the pre-existing failures against baseline, and drafting this description. Reviewed by me.
This ticket was mentioned in Slack in #core-performance by westonruter. View the logs.
3 months ago
@westonruter commented on PR #13084:
3 months ago
#36
This remains high on my radar to get back to. I want to address the comments I raised and add some tests, but then, yes, we should commit!
This ticket was mentioned in Slack in #core-performance by westonruter. View the logs.
8 weeks ago
@westonruter commented on PR #13084:
7 weeks ago
#38
🤖 _Comment by Claude Opus 5.5_
Benchmarks: prefetch reuse, what to prefetch, and slow connections
These were run on 2026-09-25/26 against this branch as of 87e9460df5 (before 9818520732 narrowed the login set, which was chosen on the strength of the results below).
Setup
Unless stated otherwise:
- Chrome driven through the DevTools protocol, with DevTools' own Fast 4G and Fast 3G network presets.
- A fresh isolated browser context per run, so every run starts with an empty cache and no cookies.
- A real login: the login screen is loaded, credentials are filled in, and the form is submitted after a fixed delay measured from the login screen's
loadevent, simulating the time spent typing. Metrics are read on the Dashboard the login redirects to. CONCATENATE_SCRIPTSfalse andSCRIPT_DEBUGfalse, so minified files and no concatenation, the case this PR targets.- Local
wp-envover HTTP/1.1, so six connections per origin. The local server sends noCache-ControlorExpiresfor static files, onlyLast-ModifiedandETag. - Timings come from Navigation Timing,
largest-contentful-paintandpaintentries, and Resource Timing, all relative to the start of the login form's POST, so they include the redirect. Cache hits are resources with atransferSizeof 0 on the Dashboard. - Medians of 10 runs, with the full range in brackets.
1. Are prefetched responses reused across the navigation?
This had been verified for the first revision's preload, but not for prefetch.
| Login submitted | Served from cache, no request | Revalidated (304) |
| --- | ---: | ---: |
| ~4 s after the prefetch | 24 / 24 | 0 |
| 241 s after the prefetch | 6 | 18 |
Yes, but only for as long as ordinary HTTP freshness allows. With no explicit caching headers, Chrome gives each file a heuristic lifetime of a tenth of the time since its Last-Modified. The 18 files that revalidated at 241 s were exactly those whose lifetime had run out: they had been rebuilt minutes earlier, giving lifetimes of 61–105 s. The six that stayed cache hits were old enough to be fresh for hours or days. No five-minute exemption for unused prefetches applied. A 304 still saves the body (about 300 bytes crossed the wire) but costs a round trip, which was 170–860 ms each under Fast 4G.
A freshly built checkout is close to the worst case for this. On a production site core's files are typically unchanged for weeks, and many hosts send a long max-age besides.
2. What actually blocks LCP on the Dashboard?
One cold-cache Dashboard load under Fast 4G:
- LCP was 1556 ms, on the "Welcome to WordPress!" heading, which was also the first paint.
- Chrome's
renderBlockingStatusmarks 31 resources as blocking: 28 stylesheets and 3 scripts,jquery,jquery-migrateandutils. Those three are exactly the scripts printed in the head. - Footer scripts didn't hold up LCP. 99 of the 104 files loaded in the body finished after LCP, the last one at 4443 ms.
- The prefetch set, as it stood, missed two things. It covered 21 of the 31 blocking resources, and the login screen loads 6 more itself. It also included three files that don't block rendering:
hoverIntent,wp-dom-readyandwp-hooks. They were in the headload-scripts.phpbundle, but with concatenation off they print in the footer. The 4 blocking resources left uncovered are expected:site-healthandthickboxstylesheets: Dashboard-only.- A plugin stylesheet.
colors: the per-user color scheme.
3. What loads on every admin screen but isn't prefetched?
12 admin screens were fetched, and the core scripts and stylesheets present on every one were kept:
| Group | Files | Gzipped |
| --- | ---: | ---: |
| Prefetched from the login screen | 24 | 121 KB |
| Already loaded by the login screen itself | 8 | 49 KB |
| Loaded on every admin screen, not prefetched | 50 | 1,110 KB |
Of the 50, colors.css is the per-user scheme. The other 49 are blocking footer scripts:
- About 14 KB:
common,hoverintent-js,admin-bar,heartbeat,svg-painterandwp-auth-check. - About 1,090 KB: the command palette's dependencies.
wp_enqueue_command_palette_assets()runs on every admin screen, and itswp-core-commandsdepends onwp-core-data, which depends onwp-block-editor(467 KB) andwp-components(260 KB), among others.
4. Which set should the login screen prefetch?
Three sets were compared by adding or removing entries through the prefetch_admin_assets filter:
| Arm | Prefetched from the login screen | Links |
| --- | --- | ---: |
| A | The concatenated set, as this PR had it: 18 stylesheets and 6 scripts | 24 |
| B | A without hoverIntent, wp-dom-ready and wp-hooks, leaving only what blocks rendering. Now the PR's behavior | 21 |
| C | B plus all 73 blocking footer scripts the Dashboard loads (about 1.2 MB gzipped) | 94 |
Fast 4G, login submitted 3 s after the login screen loaded (10 runs per arm):
| Arm | Done at submit | Cache hits on Dashboard | LCP | DCL | Load |
| --- | ---: | ---: | ---: | ---: | ---: |
| A | 24 / 24 | 24 | 900 [872–940] | 3691 [3644–3762] | 3923 |
| B | 21 / 21 | 21 | 894 [860–1036] | 3607 [3579–3748] | 3875 |
| C | 94 / 94 | 94 | 896 [852–1060] | 1049 [1006–1225] | 1393 |
- A vs B: no difference beyond noise. Dropping the three footer scripts costs nothing.
- C: LCP unchanged, while DCL falls by 2.56 s (−71%) and
loadby 2.48 s. The DCL ranges don't overlap.
Fast 3G, login submitted 3 s after the login screen loaded (10 runs each of B and C):
| Arm | Done at submit | Cache hits on Dashboard | Dashboard HTML responseStart | LCP | DCL | Load |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| B | 21 / 21 | 21 | 942 | 1860 [1852–1868] | 13513 | 14237 |
| C | 25 / 94 | 42 | 1042 | 2434 [2264–2688] | 11886 [7832–11946] | 12608 |
Fast 3G, login submitted 8 s after the login screen loaded (10 runs each):
| Arm | Done at submit | Cache hits on Dashboard | Dashboard HTML responseStart | LCP | DCL | Load |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| B | 21 / 21 | 21 | 945 | 1860 [1852–1868] | 13522 | 14247 |
| C | 72 / 94 | 89 | 1163 | 2898 [2844–2924] | 6574 [6538–6605] | 7299 |
On Fast 3G, C improves DCL by 1.6 s with the 3 s delay and 6.9 s with the 8 s delay. But it makes LCP worse by 574 ms and 1,038 ms respectively, and the LCP ranges don't overlap B's in either case. More typing time made LCP worse, not better:
- With 8 s:
- Unfinished prefetches kept downloading after submit. 22 were still downloading at submit, but 89 of the 94 were cache hits on the Dashboard. So 17 of those finished after the page changed and were reused, and only 5 small files were downloaded again.
- The Dashboard's HTML arrived 218 ms later, and the time from that response to first paint grew from about 915 ms to about 1735 ms.
- This is consistent with the remaining large command-palette files competing with the Dashboard's render-blocking stylesheets for bandwidth.
- With 3 s: far fewer prefetches carried over. Only 42 were cache hits and about 52 were downloaded again by the Dashboard itself, at footer-script priority after the stylesheets. That fits the smaller LCP cost.
The competition for bandwidth is inferred from these counts and timings; it wasn't traced at the network level. By the rate observed, the full C set needs roughly 11–12 s to finish on Fast 3G.
One C run with the 3 s delay was an outlier: 63 of 94 prefetches had finished at submit, and DCL was 7832 ms. It was the first run of that series and immediately followed a browser page that failed to open. It is kept in the data above.
The login screen itself was unaffected by the prefetch set's size. Its load event was 902–913 ms on Fast 4G in all three arms, including the 94-link one, and 3154–3188 ms on Fast 3G in both B and C. The first revision's preload had pushed it from 908 ms to 1597 ms. That regression was a preload artifact and is gone.
Conclusions
- Prefetched responses are reused across the login redirect. How long they stay reusable depends on the static files' HTTP freshness, not on anything specific to prefetch.
- LCP on the admin is blocked only by the stylesheets and the three head scripts, so that is the right set to prefetch from the login screen. It is safe on both connection speeds tested. It is now the PR's behavior (9818520732).
- Prefetching the footer scripts too roughly halves DCL and
loadwhen it finishes before the login is submitted. It makes LCP 0.6–1.0 s worse on Fast 3G when it doesn't finish, which even an 8 s delay wasn't enough for. Plain<link rel="prefetch">tags can't abandon a prefetch that's still downloading when the form is submitted. Afetch()with anAbortControllercancelled on submit might keep the gain without the cost. That hasn't been tried, and it's unverified whether a response cached byfetch()is reused by a later<script>.
Caveats
- One machine, one site, one page (the Dashboard), over HTTP/1.1 on localhost with DevTools throttling. Over HTTP/2 the request-count effects would shrink.
- Only Chrome was tested.
- The recovery against a no-prefetch control hasn't been re-run for the current implementation. The PR description still carries the first revision's figures for that.
- The editor case, Dashboard → Add New Post, hasn't been benchmarked.
@westonruter commented on PR #13084:
7 weeks ago
#39
🤖 _Comment by Claude Opus 5.5_
Does prefetch reuse depend on far-future caching headers?
No. A prefetched file is served from the cache without a request whenever it is still *fresh*. Freshness doesn't need an explicit max-age: for most sites it comes from Last-Modified, as the conditions below explain.
How long a response stays fresh without caching headers
If a response has no Cache-Control: max-age and no Expires, the browser estimates how long it stays fresh from Last-Modified. RFC 9111 §4.2.2 suggests using 10% of the time since the file was last modified, and Chrome does exactly that. The benchmarks above show it working:
| Login submitted | Server's caching headers | Cache hits, no request | Revalidated (304) |
| --- | --- | ---: | ---: |
| ~4 s after the prefetch | Last-Modified and ETag only | 24 / 24 | 0 |
| 241 s after the prefetch | Last-Modified and ETag only | 6 / 24 | 18 |
| 241 s after the prefetch | Cache-Control: max-age=31536000 | 21 / 21 | 0 |
At 241 s, the six files that were still cache hits were the ones old enough for their estimated freshness to cover the wait. The 18 that revalidated had been rebuilt minutes before the test. With an explicit one-year max-age, every file was a cache hit.
The last row used an opt-in far-future expires setting for the local Docker environment's nginx. It will be proposed in its own ticket, since it's useful for performance testing generally: without it, local caching depends on how recently the assets were built.
When prefetch reuse works
A prefetched file is reused without revalidation when all of these hold:
- No caching directive overrides the estimate. Estimated freshness applies only when the response has neither
max-agenorExpires. A server sendingCache-Control: no-cache,max-age=0, or anExpiresin the past forces a revalidation every time. An explicit longmax-agealso works. Last-Modifiedis sent. nginx and Apache send it for static files by default. A server or CDN that sends only anETaggives the browser nothing to estimate from, so every reuse becomes a 304.- The file is old enough compared with the wait before login. It needs to be about ten times older than the time between the prefetch and the login. A login 30 s after the prefetch needs files at least 5 minutes old; a login 5 minutes later needs them at least 50 minutes old. In production, core's files normally don't change between updates, so this fails mainly just after a core update or deploy.
When any of these don't hold, the prefetch still saves the download: the Dashboard sends a conditional request and gets a 304 instead of the file. It never makes things worse than not prefetching.
Two limits to this:
- Only Chrome was tested. Chrome estimated freshness for URLs with a
?ver=query string, which applies to almost every core asset. RFC 2616 used to tell caches not to do that for URLs with query strings; RFC 9111 dropped that rule. Firefox and Safari haven't been checked. - The benchmarks were local only, on the server described in the benchmark comment above.
What HTTP Archive and the Web Almanac say
No published data breaks static-asset caching down by CMS, so there's no WordPress-specific figure. Across all sites:
- Web Almanac 2021, Caching, the most recent dedicated caching chapter:
- About 74–75% of responses include
Cache-Control, about 55% includeExpires, and about 25% include neither. - The median
max-agefor scripts and CSS is 30 days, and 30 days is the most common value overall. - So long
max-agevalues are widespread for static files, but far from universal.
- About 74–75% of responses include
- Web Almanac 2022, Sustainability repeats that more than a quarter of sites send no caching headers at all. It breaks page weight down by CMS, but not caching.
- Web Almanac 2024, Sustainability has a "Caching" heading with no data under it.
For this PR, what matters is conditions 1 and 2 above, not how common far-future caching is, so this data isn't needed to judge it.
Why it matters for Core-57548
The broader ticket does depend on this. load-scripts.php and load-styles.php send their own caching headers:
$expires_offset = 31536000; // 1 year. header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); header( "Cache-Control: public, max-age=$expires_offset" );
On a server with no caching rules for static files, retiring concatenation replaces bundles cached for a year with individual files that only get estimated freshness. Repeat visits would stay cached for most of a release cycle, but revalidate more after each update. How many WordPress sites are in that position is something HTTP Archive can answer. HTTP Archive only crawls public pages, never wp-admin, but the same server rules normally cover /wp-includes/, which the front end loads from. The query below is a starting point. It hasn't been run yet, and should get a dry run first to check how much data it scans:
<details>
<summary>Draft HTTP Archive query: caching headers on WordPress core JS and CSS</summary>
-- JS and CSS that WordPress sites serve from their own core directories, -- bucketed by explicit freshness lifetime. One crawl, mobile, root pages. DECLARE crawl DATE DEFAULT '2026-08-01'; WITH wp_pages AS ( SELECT DISTINCT page FROM `httparchive.crawl.pages` WHERE date = crawl AND client = 'mobile' AND is_root_page AND EXISTS (SELECT 1 FROM UNNEST(technologies) AS t WHERE t.technology = 'WordPress') ), core_assets AS ( SELECT r.page, r.type, LOWER((SELECT STRING_AGG(h.value, ', ') FROM UNNEST(r.response_headers) AS h WHERE LOWER(h.name) = 'cache-control')) AS cache_control, EXISTS (SELECT 1 FROM UNNEST(r.response_headers) AS h WHERE LOWER(h.name) = 'expires') AS has_expires, EXISTS (SELECT 1 FROM UNNEST(r.response_headers) AS h WHERE LOWER(h.name) = 'last-modified') AS has_last_modified FROM `httparchive.crawl.requests` AS r JOIN wp_pages USING (page) WHERE r.date = crawl AND r.client = 'mobile' AND r.is_root_page AND r.type IN ('script', 'css') AND NET.HOST(r.url) = NET.HOST(r.page) -- served by the site itself, not a CDN rewrite AND REGEXP_CONTAINS(r.url, r'/wp-(?:includes|admin)/') ), classified AS ( SELECT *, SAFE_CAST(REGEXP_EXTRACT(cache_control, r'(?:^|[,\s])max-age\s*=\s*"?(\d+)') AS INT64) AS max_age FROM core_assets ) SELECT type, CASE WHEN REGEXP_CONTAINS(IFNULL(cache_control, ''), r'no-store|no-cache') OR max_age = 0 THEN '1: always revalidate' WHEN max_age IS NULL AND NOT has_expires AND has_last_modified THEN '2: heuristic only (Last-Modified)' WHEN max_age IS NULL AND NOT has_expires THEN '3: no freshness, no Last-Modified' WHEN max_age IS NULL THEN '4: Expires only' WHEN max_age < 86400 THEN '5: under 1 day' WHEN max_age < 2592000 THEN '6: 1 to 29 days' WHEN max_age < 31536000 THEN '7: 30 days to under 1 year' ELSE '8: 1 year or more' END AS freshness, COUNT(DISTINCT page) AS sites, COUNT(*) AS responses, ROUND(100 * COUNT(*) / SUM(COUNT(*)) OVER (PARTITION BY type), 1) AS pct_of_responses FROM classified GROUP BY type, freshness ORDER BY type, freshness;
The schema follows the `requests` and `pages` table references. The "Expires only" bucket isn't converted into a lifetime.
</details>
@westonruter commented on PR #13084:
7 weeks ago
#40
🤖 _Comment by Claude Opus 5.5_
Benchmarks: today's default vs this PR, login → Dashboard
These replace the first revision's figures in the PR description. They compare WordPress's current default (concatenation on) with this PR's configuration (concatenation off, prefetching on), plus a control arm with concatenation off and no prefetching. The runs were on 2026-09-26 against this branch at 9818520732, with the local nginx caching option from a separate commit enabled.
Setup
- Browser: Chrome, driven through the DevTools protocol, using DevTools' own Fast 4G and Slow 4G network presets.
- A fresh isolated browser context per run, so every run starts with an empty cache and no cookies.
- A real login each run: the login screen loads, credentials are filled in, and the form is submitted 3 s after the login screen's
loadevent. Metrics are read on the Dashboard the login redirects to. - Settings:
SCRIPT_DEBUGoff. Concatenation is switched per arm with theCONCATENATE_SCRIPTSconstant, on both the login screen and the Dashboard. - Server: local
wp-envover HTTP/1.1, with gzip on and static files served withCache-Control: max-age=31536000, as a typical production host would. - Timings: from Navigation Timing and the
paintandlargest-contentful-paintentries. They're measured from the start of the login form's POST, so they include the redirect. Request counts and bytes cover only what the Dashboard fetched over the network. - 10 runs per arm, with the arms interleaved (concat, none, prefetch, concat, …). Medians are reported, with the full range in brackets.
| Arm | Concatenation | Login screen prefetches |
| --- | --- | ---: |
| concat | on (today's default) | 0 (the concatenation check suppresses them) |
| none | off | 0 (removed through the prefetch_admin_assets filter)
|
| prefetch | off | 21 (this PR) |
Fast 4G
| concat | none | prefetch | |
| --- | ---: | ---: | ---: |
| LCP | 1134 [1104–1164] | 1412 [1360–1536] | 840 [824–880] |
| FCP | 1124 [1088–1164] | 1412 [1360–1536] | 840 [824–880] |
| DOMContentLoaded | 3596 [3553–3640] | 4105 [4057–4246] | 3650 [3626–3668] |
load | 3597 [3555–3641] | 4107 [4058–4248] | 3651 [3627–3669] |
| Dashboard requests over the network | 83 | 118 | 99 |
| Dashboard bytes transferred | 1,511 KB | 1,456 KB | 1,367 KB |
| Login screen FCP | 532 | 588 | 584 |
Login screen load | 698 | 920 | 912 |
Slow 4G
| concat | none | prefetch | |
| --- | ---: | ---: | ---: |
| LCP | 3494 [3464–3508] | 3806 [3764–3836] | 1872 [1852–1880] |
| FCP | 3474 [3460–3508] | 3806 [3764–3836] | 1872 [1852–1880] |
| DOMContentLoaded | 13286 [13265–13309] | 15207 [15174–15241] | 13302 [13286–13325] |
load | 13287 [13266–13310] | 15209 [15176–15243] | 13303 [13287–13326] |
| Dashboard requests over the network | 81 | 116 | 97 |
| Dashboard bytes transferred | 1,490 KB | 1,437 KB | 1,346 KB |
| Login screen FCP | 1892 | 1812 | 1812 |
Login screen load | 2418 | 3195 | 3181 |
In current Chrome, "Slow 4G" is the preset formerly named "Fast 3G". The prefetch arm's LCP of 1872 ms matches the earlier Fast 3G runs of the same set (1860 ms), which is consistent with that.
Findings
- LCP is much faster than today's default: 294 ms (−26%) faster on Fast 4G and 1,622 ms (−46%) faster on Slow 4G. The three arms' LCP ranges don't overlap on either network.
- DOMContentLoaded and
loadare essentially unchanged: +54 ms (+1.5%) on Fast 4G and +16 ms (+0.1%) on Slow 4G. The prefetch doesn't cover footer scripts, which is where the admin's bytes mostly are. Those download after the redirect in every arm. - Retiring concatenation with no mitigation costs: 278–312 ms of LCP, 509 ms of DOMContentLoaded on Fast 4G, and 1.9 s of it on Slow 4G. Prefetching recovers all of that for LCP and nearly all of it for DOMContentLoaded.
- Why the prefetch arm beats concatenation on LCP: the login screen concatenates too when the constant is on, into a bundle of its own:
load-styles.php?…load[chunk_0]=dashicons,buttons,forms,l10n,wp-base-styles,wp-tooltip,login. The Dashboard's bundles combine different handles, so it can reuse nothing and downloads everything from scratch. With concatenation off, the Dashboard reused the six files the login screen had already loaded plus all 21 prefetched ones. Every prefetched file was a cache hit in every run of the prefetch arm. - Not all of the lead comes from dropping concatenation. Some of it comes from prefetching as such. A concatenated setup could in principle prefetch its own bundle URLs from the login screen, though they differ per admin screen. That hasn't been measured.
- The login screen's own cost comes from concatenation being off, not from the prefetch. Its
loadrises by 214 ms on Fast 4G and 777 ms on Slow 4G, the same in the no-prefetch and prefetch arms. Its FCP barely moves.
Correction
Earlier revisions of the description said the login screen never concatenates, even with the constant on. On this setup it does, as the bundle URL above shows. Whether it does depends on whether script_concat_settings() runs before login_init; the PR description now says so.
Caveats
- One machine, one site, one page (the Dashboard), over HTTP/1.1 on localhost with DevTools throttling. Over HTTP/2 the effects of request count shrink, which should narrow the gaps between the arms.
- Only Chrome was tested, and only with fresh browser contexts. Repeat logins with a warm cache weren't measured; the arms should converge there.
- The login is submitted 3 s after the login screen loads. That's enough for the 21-file prefetch to finish on both networks.
- The editor case (Dashboard → Add New Post) hasn't been benchmarked.
@westonruter commented on PR #13084:
7 weeks ago
#42
🤖 _Comment by Claude Opus 5.5_
Benchmark: login → Dashboard → Posts list → block editor
The earlier benchmarks stopped at the Dashboard. This one follows a longer user journey to see whether the gains carry forward to later screens, and how the block editor is affected:
- Log in (3 seconds on the login screen before submitting).
- Dashboard.
- Posts list (
edit.php). - Edit "Hello world!" in the block editor (
post.php?post=1&action=edit).
Three arms were compared:
- concat:
CONCATENATE_SCRIPTSon, i.e. the current default behavior. - none: concatenation off, nothing prefetched.
- prefetch: concatenation off, with this PR's prefetching.
Method
- Chrome via DevTools MCP, each journey in a fresh isolated browser context (cold cache).
- Fast 4G and Slow 4G network emulation.
SCRIPT_DEBUGoff; static assets served withLOCAL_NGINX_STATIC_EXPIRES=1y(see Core-66194, committed in r63946) so that individual files are cacheable like the concatenated bundles are.- 3 runs per arm per network, interleaved. Runs landed within about 1–2% of each other, so the medians are stable.
- The block editor renders its content inside the
editor-canvasiframe, so the parent document's LCP is not meaningful there. It is replaced with Editor ready: the time at which the post title "Hello world!" is visible in the canvas.
All figures are medians. In the last two columns, negative means prefetch is lower, which is better for every metric shown.
Fast 4G
Login screen
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 524 | 572 | 580 | +11% | +1% |
| Onload (ms) | 692 | 912 | 915 | +32% | +0% |
Dashboard
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 1,148 | 1,424 | 864 | −25% | −39% |
| LCP (ms) | 1,148 | 1,424 | 864 | −25% | −39% |
| DCL (ms) | 3,607 | 4,056 | 3,684 | +2% | −9% |
| Onload (ms) | 3,608 | 4,057 | 3,686 | +2% | −9% |
| Requests | 81 | 98 | 95 | +17% | −3% |
| Transferred (KB) | 1,492 | 1,334 | 1,344 | −10% | +1% |
Posts list
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 576 | 236 | 244 | −58% | +3% |
| LCP (ms) | 576 | 236 | 244 | −58% | +3% |
| DCL (ms) | 703 | 529 | 541 | −23% | +2% |
| Onload (ms) | 713 | 539 | 550 | −23% | +2% |
| Requests | 5 | 4 | 4 | −20% | +0% |
| Transferred (KB) | 175 | 28 | 28 | −84% | +0% |
Block editor
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 1,208 | 1,210 | 676 | −44% | −44% |
| Editor ready (ms) | 3,598 | 3,684 | 3,198 | −11% | −13% |
| DCL (ms) | 3,055 | 3,316 | 2,832 | −7% | −15% |
| Onload (ms) | 3,066 | 3,328 | 2,844 | −7% | −15% |
| Requests | 47 | 62 | 45 | −4% | −27% |
| Transferred (KB) | 2,220 | 1,897 | 1,794 | −19% | −5% |
Slow 4G
Login screen
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 1,896 | 1,816 | 1,800 | −5% | −1% |
| Onload (ms) | 2,420 | 3,180 | 3,187 | +32% | +0% |
Dashboard
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 3,484 | 3,804 | 1,860 | −47% | −51% |
| LCP (ms) | 3,492 | 3,804 | 1,860 | −47% | −51% |
| DCL (ms) | 13,286 | 14,532 | 13,290 | +0% | −9% |
| Onload (ms) | 13,288 | 14,533 | 13,291 | +0% | −9% |
| Requests | 81 | 98 | 96 | +19% | −2% |
| Transferred (KB) | 1,492 | 1,334 | 1,346 | −10% | +1% |
Posts list
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 2,108 | 632 | 624 | −70% | −1% |
| LCP (ms) | 2,108 | 648 | 648 | −69% | +0% |
| DCL (ms) | 2,218 | 1,442 | 1,428 | −36% | −1% |
| Onload (ms) | 2,228 | 1,451 | 1,438 | −35% | −1% |
| Requests | 5 | 4 | 4 | −20% | +0% |
| Transferred (KB) | 175 | 28 | 28 | −84% | +0% |
Block editor
| Metric | concat | none | prefetch | prefetch vs concat | prefetch vs none |
| --- | ---: | ---: | ---: | ---: | ---: |
| FCP (ms) | 4,730 | 3,366 | 1,434 | −70% | −57% |
| Editor ready (ms) | 15,097 | 14,632 | 12,790 | −15% | −13% |
| DCL (ms) | 13,586 | 13,804 | 11,970 | −12% | −13% |
| Onload (ms) | 13,598 | 13,817 | 11,982 | −12% | −13% |
| Requests | 47 | 62 | 45 | −4% | −27% |
| Transferred (KB) | 2,220 | 1,897 | 1,794 | −19% | −5% |
Observations
- Login screen: onload is 32% higher than with concatenation because the 21 prefetch requests are counted in it. FCP is within 1% of the no-prefetch arm, so the prefetching is not visible to the user.
- Dashboard: the earlier login → Dashboard results are reproduced. On Slow 4G, LCP is roughly halved compared with concatenation (1.86 s vs 3.49 s), and DCL and onload match concatenation while being about 1.2 s faster than no prefetching.
- Posts list: concatenation is slowest here. The
load-scripts.phpandload-styles.phpbundles are specific to each screen's handle list, so the list screen re-downloads 175 KB of assets that are already cached as individual files. On Slow 4G that costs about 1.5 s of FCP. Without concatenation, only the HTML (28 KB) is fetched, with or without prefetching. - Block editor: prefetching leads on every metric. Because the Dashboard and list table screens prefetch the render-blocking assets of the "Add New Post" screen, which is the block editor, those assets are already cached when an existing post is opened (45 requests instead of 62). On Slow 4G, FCP drops from 4.7 s with concatenation to 1.4 s, and the editor is ready 2.3 s sooner. The concatenated editor also transfers 19% more, because its bundles duplicate files already cached from earlier screens.
@westonruter commented on PR #13084:
7 weeks ago
#43
This looks good to me as a starting point. Should we commit it?
@manzoorwanijk I did a bunch more performance benchmarking to verify that prefetching is a win (it is). I also refactored the logic to eliminate logic duplication among other improvements. I also added the missing tests.
Ready for review (and commit).
Then we can move forward with https://github.com/WordPress/wordpress-develop/pull/13090 from @haqadn.
@sergiomdgomes commented on PR #13084:
7 weeks ago
#44
Hey @westonruter!
First of all, thank you for this PR, it's always great to see performance explorations and work on Core! 🙌
I've had some trouble figuring out the intent and the scope of this effort, however, since the PR description is quite dense, extremely long, and not particularly clear.
Prefetching and concatenation aren't generally equivalent, and they serve different needs. Prefetching is a mechanism for taking advantage of idle network time to download something we expect to be useful later; whereas concatenation is a mechanism to reduce the number of resources being fetched, and thus save some potentially lengthy roundtrips. I understand the idea of using prefetching as a mitigation strategy for removing concatenation, but this comes with a number of assumptions: that there is enough time and bandwidth for the prefetch to happen, that we guess the destination right, and that the user's bandwidth was indeed free for us to use without a negative impact to them.
While I don't have any objection to prefetching wp-admin in the login screen (seems very reasonable), nor to prefetching the editor while in the dashboard or the post lists (less certain, but not an unlikely next step), I worry about the perception that this comes as a replacement for concatenation.
I'm also particularly worried by some of the language you use in the PR description: "Two contexts qualify today."
To me, this raises a number of questions:
- Why do these and not others qualify? That is, what are the criteria for or against?
- Why "today"? Do we expect things to change in the future? Do we expect the criteria themselves to?
- While the Core ticket refers to
wp-adminspecifically, the PR description isn't as explicitly narrow, and leaves room for an eventual expansion to regular page views. Is that part of the goals?
The code itself is also somewhat hard to read, with needlessly detailed and verbose comments. But one particularly troubling thing is hidden there in the midst of the new file: hardcoded resource handles. Taking a step back and trying to read the overall approach (which, again, is pretty hard when comments are this long and dense), this looks like a fragile and overly specific mechanism that comes with added maintenance costs, particularly as you factor in potential interactions with plugins and the like.
If the goal is to prefetch page resources in qualifying circumstances, with a view to make it more generic and prevalent over time, should we really be hand-rolling custom loaders for specific pages? Is this approach scalable?
Sorry for coming in with my comments quite late here, but I didn't have a chance until now.
@westonruter commented on PR #13084:
7 weeks ago
#45
@sgomes Thanks for the comments!
I've had some trouble figuring out the intent and the scope of this effort, however, since the PR description is quite dense, extremely long, and not particularly clear.
Sorry about that. This PR was part of a hackathon at WCUS that @manzoorwanijk and @haqadn and I were rapidly collaborating on, so it wasn't as clear and concise as it could have been.
Prefetching and concatenation aren't generally equivalent, and they serve different needs. Prefetching is a mechanism for taking advantage of idle network time to download something we expect to be useful later; whereas concatenation is a mechanism to reduce the number of resources being fetched, and thus save some potentially lengthy roundtrips. I understand the idea of using prefetching as a mitigation strategy for removing concatenation, but this comes with a number of assumptions: that there is enough time and bandwidth for the prefetch to happen, that we guess the destination right, and that the user's bandwidth was indeed free for us to use without a negative impact to them.
Agreed. They aren't equivalent. However, in the benchmarking (https://github.com/WordPress/wordpress-develop/pull/13084#issuecomment-5851941039) you can see that prefetching is a clear performance win for navigating from the login screen to the dashboard to the posts list table and then to the editor. Similar performance wins were observed by @haqadn in his benchmarking in https://github.com/WordPress/wordpress-develop/pull/13084#issuecomment-5309952172 and by @manzoorwanijk in https://github.com/WordPress/wordpress-develop/pull/13084#issuecomment-5309916537.
Most importantly the elimination of the concatenation bundles ensures that the individual resources can be cached separately. The Login screen, Dashboard, Posts screen, and the Add Post screen all use _different_ concatenation bundles for styles, which means none of them will be served from cache when accessed from the first time:
| Screen | Bundle |
|---|---|
| Login | dashicons, buttons, forms, l10n, wp-base-styles, wp-tooltip, login |
| Dashboard | dashicons, admin-bar, site-health, common, forms, admin-menu, dashboard, list-tables, edit, revisions, media, themes, about, nav-menus, wp-pointer, widgets, site-icon, l10n, wp-base-styles, wp-tooltip, buttons, wp-auth-check, wp-theme, wp-components, wp-commands
| Posts Screen | dashicons, admin-bar, site-health, common, forms, admin-menu, dashboard, list-tables, edit, revisions, media, themes, about, nav-menus, wp-pointer, widgets, site-icon, l10n, wp-base-styles, wp-tooltip, buttons, wp-auth-check, wp-theme, wp-components, wp-commands |
| Add Post | dashicons, admin-bar, buttons, media-views, editor-buttons, wp-theme, wp-components, wp-preferences, wp-block-editor, wp-reusable-blocks, wp-patterns, wp-media-utils, wp-editor, wp-base-styles, common, forms, wp-reset-editor-styles, wp-block-library, wp-block-editor-content, wp-edit-blocks, wp-commands, wp-edit-post, wp-block-directory, wp-format-library, admin-menu, dashboard, list-tables, edit, revisions, media, themes, about, nav-menus, wp-pointer, widgets, site-icon, l10n, wp-tooltip, wp-auth-check
This means at every screen, the user has to re-download dashicons, buttons, forms, l10n, wp-base-styles, and wp-tooltip as part of separate bundles.
Beyond the performance gains, eliminating concatenation addresses many defects that arise from load-scripts.php and load-styles.php:
<details><summary>Defects caused by concatenation (9 tickets)</summary>
Concatenation has also been a steady source of defects, for example:
- Core-65515: When the first concatenated script is in strict mode, every script after it in the
load-scripts.phpbundle runs in strict mode too, which breaks ThickBox (ReferenceError: imgLoader is not defined). Forcing sloppy mode instead would break scripts that rely on strict semantics. - Core-63908: When styles are concatenated in more than one batch, each later batch prints the earlier batches' inline styles again.
- Core-64087:
load-styles.phpemits a PHP 8 deprecation warning becauseget_stylesheet_directory()is empty in that context. Bothload-scripts.phpandload-styles.phpdisable error reporting to hide warnings like this one. - Core-47322: A bug in
load-styles.php, whose patch is also expected to lower the peak memory it needs. - gutenberg#54294: Concatenation fails with an HTTP 503 on hosts with less than about 1.5–1.9 GB of memory.
The compression side of the same system, which exists only to serve the concatenated bundles, has defects of its own:
- Core-63017: The
COMPRESS_CSS,COMPRESS_SCRIPTSandENFORCE_GZIPconstants, and thecparameter on the bundle URLs, no longer do anything, but are still set and documented. - Core-66053: Site Health still lists
COMPRESS_SCRIPTSandCOMPRESS_CSS. - Core-65750:
compression_test()runs for users withoutmanage_options, so its AJAX requests fail with-1. - Core-65980:
compression_test()produces a 400 error whenadmin_url()is filtered to include a query string, such as a translation plugin's?lang=en.
🤖 _Report generated by Claude Opus 5.5_
</details>
So I see this as a win-win: improvement to performance as well as eliminating technical debt.
Why do these and not others qualify? That is, what are the criteria for or against?
The goal here is to identify the critical user journeys that should in particular be optimized for. These CUJs are the "Two contexts qualify today" being referred to. The two are logging in and landing on the Dashboard, and the other is navigating from the Dashboard to the posts screen and to the edit post screen. In reality, most of the scripts and styles are shared by all screens in the admin. So once the dashboard's scripts and styles resources have been loaded, they can be reused on other screens (assuming they aren't in a bundle that concatenates with unique scripts and styles!).
Why "today"? Do we expect things to change in the future? Do we expect the criteria themselves to?
For future enhancements, I could see extending this to prefetch resources used by the Site Editor, for example. Mainly restricting this to the main CUJs was to limit scope. However, since the Site Editor shares much of the same styles as the Post Editor, in reality this CUJ is also optimized for.
If at some point we introduce some big new area of the admin that has a lot of unique JS and CSS, then this would signal possibly an opportunity to optimize for another CUJ.
While the Core ticket refers to wp-admin specifically, the PR description isn't as explicitly narrow, and leaves room for an eventual expansion to regular page views. Is that part of the goals?
I think it is is specifically for the admin, actually. The function introduced is called such: wp_prefetch_admin_assets().
But one particularly troubling thing is hidden there in the midst of the larger file: hardcoded resource handles. […] If the goal is to prefetch page resources in qualifying circumstances, with a view to making it more generic and prevalent over time, should we really be hand-rolling custom loaders for specific pages? Is this approach scalable?
An earlier version of this PR had many more hard-coded handles. This has been very recently streamlined to just 2 scripts and 11 styles:
https://github.com/WordPress/wordpress-develop/blob/d40ea0fd9ca25d6d7309256deaf20fcad6ced958/src/wp-includes/script-loader.php#L2686-L2689
https://github.com/WordPress/wordpress-develop/blob/d40ea0fd9ca25d6d7309256deaf20fcad6ced958/src/wp-includes/script-loader.php#L2691-L2697
https://github.com/WordPress/wordpress-develop/blob/d40ea0fd9ca25d6d7309256deaf20fcad6ced958/src/wp-includes/script-loader.php#L2725-L2735
That said, we could look at adding this logic to the registered scripts and styles themselves. For example, we introduce a new prefetch_condtion_callback (or something) which is registered on each script and style. This callback could be called to determine whether or not it is added to the $script_roots or $style_roots. That would eliminate the hard-coding in wp_prefetch_admin_assets().
this looks like a fragile and overly specific mechanism that comes with added maintenance costs, particularly as you factor in potential interactions with plugins and the like.
The reality is that concatenation is limited to built-in _core_ scripts and styles to begin with. So the scripts and styles have always been excluded from any performance benefits of concatenation. With this PR, themes and plugins now have the ability to opt-in to optimizing for their flows via the prefetch_admin_assets filter.
In terms of maintenance, this seems like something that could be accounted for with an E2E test which would verify that the prefetched resources on one screen do indeed occur on the next screen. It could also identify other resources which could be prefetched. I think this should be tackled in a separate ticket, given that this is getting excessively large, as you rightly noted.
@sergiomdgomes commented on PR #13084:
7 weeks ago
#46
Thank you for the detailed reply, @westonruter! I feel like I have a much better grasp of the goals you had in mind here, and why you made the choices you did.
So if I understand correctly, the main goal is to make the two Critical User Journeys you mentioned faster. If so, have you given any thought to using the Speculation Rules API instead? It seems to me like it might be a better fit for this scenario:
- It doesn't involve knowing the resources ahead of time nor hardcoding them, only the CUJs themselves. There's nothing to maintain or monitor; if the resources change because of plugins or changes to Core, you don't need to do anything.
- It could be configured to just fetch the document (
prefetch) to save a single roundtrip, fetch all resources and fully render the page (prerender) to make the next step really fast and seamless, or, in the future, fetch and start to render but stop right before scripts (prerender_until_script, still behind an origin trial) to reduce the likelihood of a performance impact to the current navigation. - It generally doesn't suffer from prioritisation issues like
prefetch. Early-discovered prefetches are known to cause issues with servers that don't handle h2 prioritisation well, which are sadly still all too common. Speculation Rules prefetches / prerenders generally happen later, so they don't have this issue. - It's immensely simpler, and also declarative.
- You can tune the eagerness level to decrease the likelihood that the prerender / prefetch will be wasted. For example, maybe the login CUJ eagerness should be
immediateoreager, but the editor CUJ one should only bemoderate. - There's alredy prior art and helper methods in Core for Speculation Rules. This PR is a custom thing that would have to be reworked later if we wanted to make it generic.
In terms of browsers, Speculation Rules are Chromium-only at the moment, so there's no Firefox support as there is for <link rel=prefetch>. Safari supports neither. However, both Firefox and Safari are working on Speculation Rules.
Given that speeding up these CUJs is meant to be a progressive enhancement, I'd say that would be an acceptable level of browser support for now, and in line with previous decisions in Core.
@westonruter commented on PR #13084:
7 weeks ago
#47
So if I understand correctly, the main goal is to make the two Critical User Journeys you mentioned faster.
I think I was overly narrow when I defined these CUJs. Originally the PR was only targeting login->dashboard, and then dashboard->edit post. But since we found that almost all admin screens share the exact same scripts and styles, the prefetching logic was expanded so that if you're on the login screen and the redirect URL will take you to any admin screen, then those common render-blocking admin assets are prefetched. In this way, if you try accessing the Comments screen but are presented with a login prompt, you'll have the common admin render-blocking assets prefetched already for you there too.
There are three places where the prefetching happens:
- Login screen prefetches resources loaded on the
redirect_toURL. - Dashboard prefetches styles on the edit post screen (when the user has access).
- Posts list table also prefetches styles on the edit post screen.
If so, have you given any thought to using the Speculation Rules API instead?
Good question! Yes, this is something I've thought a lot about. In fact, I have a separate Speculative Loading Admin plugin which explores this. (I want to actually sunset this as a separate plugin and make it an opt-in feature of Speculative Loading.)
However, there are some big challenges with using speculative loading here by default:
- When on the login screen, you can't prefetch the document at the
redirect_toURL until the user has actually logged-in. This means it is impossible to get any prefetching done to discover the assets used on that page. - When the next page is detected to be the block editor (either by the user being on the Dashboard or the
redirect_to), it is problematic to prefetch (or prerender) the Add Post screen because every time you access/wp-admin/post-new.php, theget_default_post_to_edit()will create a newauto-draftpost in the DB. If you never actually go to that screen, then the DB just gets new posts created wastefully. This is why my Speculative Loading Admin plugin excludes the Add Post screen from prefetching. - None of the admin screens are able to be served from page cache, which means speculative loading will increase server load. For shared hosts, this could be a problem. This is in part why Speculative Loading in core is turned off if a user is logged-in. The Speculative Loading plugin allows an opt-in when logged-in, but it has a warning if a persistent object cache is not present. (This feature is key for membership and e-commerce sites where visitors are often logged in, naturally.)
By prefetching only static render-blocking resources known to be used on the manually-speculated next page, we bypass the concerns about server-side performance.
While Safari sadly does not support link[https://caniuse.com/link-rel-prefetch rel=prefetch] (it _is_ implemented behind a flag, as you say), it is otherwise [supported] by >80% of users globally, which is higher than the browser support for speculation rules. My assumption was that Safari users would be less affected by the lack of prefetching, since they tend to be in regions with faster internet. But in looking at the data, this seems only partly true: Safari's share is lowest in Africa, where slow connections are most common, but it is also lowest in South America, whose largest market, Brazil, has some of the fastest connections in the world. So Safari users will see a regression compared with concatenation, and it is not confined to fast networks.
<details><summary>Browser support, Safari's regional share, and connection speeds</summary>
Browser support (caniuse, September 2026):
| Feature | Global support | Not supported |
| --- | ---: | --- |
| `link[rel=prefetch`] | 81.6% | Safari on macOS and iOS (disabled by default in every version, including the Technology Preview) |
| Speculation Rules | 76.7% | Safari and Firefox (Chromium-only) |
Safari's regional share compared with connection speeds in each region's largest market
Safari's share is from StatCounter (all platforms, August 2026). Speeds are Ookla Speedtest Global Index medians for March 2026 (via Wikipedia), with global ranks in parentheses and each country's rank among the six.
| Region | Safari share | Largest market | Fixed median | Rank of 6 | Mobile median | Rank of 6 |
| --- | ---: | --- | ---: | ---: | ---: | ---: |
| Oceania | 29.4% | Australia | 154 Mbps (48th) | 3 | 117 Mbps (51st) | 4 |
| North America | 29.0% | United States | 310 Mbps (8th) | 1 | 213 Mbps (10th) | 2 |
| Europe | 17.8% | Germany | 104 Mbps (58th) | 4 | 75 Mbps (63rd) | 5 |
| Asia | 10.3% | India | 61 Mbps (86th) | 5 | 127 Mbps (36th) | 3 |
| Africa | 7.5% | Nigeria | 37 Mbps (127th) | 6 | 51 Mbps (75th) | 6 |
| South America | 5.3% | Brazil | 222 Mbps (26th) | 2 | 266 Mbps (5th) | 1 |
The relationship between Safari's share and connection speed is mixed. The slowest market, Nigeria, is in a region where Safari's share is low, but Brazil, in the region where Safari's share is lowest, has the fastest mobile and second-fastest fixed connections of the six, and India's mobile connections are faster than Australia's.
Caveats:
- A single country stands in for each region, and speeds within a region vary widely.
- Ookla medians come from people who choose to run speed tests, which skews toward better-connected users.
- Safari's share within each country differs from its regional share.
What Safari users would see: they lose concatenation without gaining prefetching, which is the "none" arm of the benchmarks. For the Dashboard, that arm's LCP was 24% slower than concatenation on Fast 4G (1,424 ms vs 1,148 ms) and 9% slower on Slow 4G (3,804 ms vs 3,494 ms).
🤖 _Report generated by Claude Opus 5.5_
</details>
So this being the case, I've added a polyfill for Safari in 89d909c32c3bf066a72230d86c2166dc7783d197. I tested it manually and I verified that resources were served from cache which had been fetched on the prior screen.
Here are the relevant HAR files:
- Login: safari-login.har.json
- Dashboard: safari-dashboard.har.json
- Add Post: safari-post-new.har.json
<details><summary>Safari: prefetch polyfill cache reuse (HAR analysis)</summary>
Since Safari does not support link[rel=prefetch], a small inline polyfill fetches the same URLs with fetch( url, { mode: 'no-cors', credentials: 'include', priority: 'low' } ) after the screen has loaded, in browsers where relList.supports( 'prefetch' ) is false. It only helps if Safari reuses those responses for the next screen's <link rel="stylesheet"> and <script> requests, which make different kinds of requests (Sec-Fetch-Dest: style or script, rather than empty). The attached HAR files, exported from Safari 27's Web Inspector, show that it does.
Method: the cache was emptied, then three screens were loaded in turn: the login screen (redirecting to the Dashboard), the Dashboard, and Add New Post. The polyfill's requests were identified by Sec-Fetch-Dest: empty, and each later request for the same URL was checked for how WebKit served it (_fetchType). Static assets were served with a one-year max-age (LOCAL_NGINX_STATIC_EXPIRES=1y).
Login screen → Dashboard: the polyfill fetched the 21 render-blocking admin assets (18 stylesheets and 3 scripts), all over the network. On the Dashboard, all 21 were requested again by its own tags:
| Requested on the Dashboard as | URLs | Served from |
| --- | ---: | --- |
Stylesheet (<link rel="stylesheet">) | 18 | Disk cache |
Script (<script>: jquery, jquery-migrate, utils) | 3 | Disk cache |
Dashboard → Add New Post: the polyfill fetched 18 editor stylesheets, 17 over the network (editor.css was already cached). On the editor, all 18 were requested again by its own <link rel="stylesheet"> tags, and all 18 came from the disk cache, including edit-post, block-editor, editor, media-views, wp-mediaelement and block-library. Three of them were requested a second time without a destination, apparently by the editor loading styles for its canvas iframe, and those came from the memory cache.
So WebKit keys these cache entries on the URL alone: a no-cors fetch() response is reused for a later stylesheet or script with the same URL, even though the request type differs.
Other observations:
- Safari honored
priority: 'low'for the polyfill's requests. - On the login screen, the fetches took about 30–40 ms each on localhost, ran in parallel, and started after the page had loaded.
Caveats:
- This is one session in one browser version, on localhost, with a one-year
max-age. It shows cache reuse, not timing, and it doesn't show how reuse behaves when static files only get a heuristic freshness lifetime. - The login went through the
reauth=1redirect to the Dashboard.
🤖 _Report generated by Claude Opus 5.5_
</details>
@sergiomdgomes commented on PR #13084:
7 weeks ago
#48
Thank you for the explanation, I agree that it does seem like prerendering isn't the best option here, at least for the login flow. Not being able to fetch the page until you're logged in is obviously a problem, and it's a bit silly I didn't think of it 🙂
So we're back to prefetch being the right choice for what this PR is trying to accomplish 👍
So if I understand correctly, the ### main goal is to make the two Critical User Journeys you mentioned faster.
I think I was overly narrow when I defined these CUJs. Originally the PR was only targeting login->dashboard, and then dashboard->edit post. But since we found that almost all admin screens share the exact same scripts and styles, the prefetching logic was expanded so that if you're on the login screen and the redirect URL will take you to any admin screen, then those common render-blocking admin assets are prefetched. In this way, if you try accessing the Comments screen but are presented with a login prompt, you'll have the common admin render-blocking assets prefetched already for you there too.
If most pages share the same scripts, this raises the question of whether the optimisation is worth the effort. While faster is always better, all things being equal, things are not equal; this PR introduces a fair bit of extra code and machinery. This needs to be weighed against not just the performance gains (which you clearly laid out, and are compelling), but also against the likelihood of the optimisation being used at all.
Assuming the presence of a concatenation-free environment for whatever reason, the issue of slightly different script sets producing a different resource to fetch isn't a concern, since all resources are fetched individually. So if most pages load the same (or similar) set of scripts, the savings would generally only be for the first page you visit on an empty cache. This likely would only be a problem for users who seldom visit admin, or for users who manage a lot of different sites on a regular basis. Loading the editor is a little different, but predicting that correctly is also harder, as I mentioned.
This seems to me like a pretty limited set of visits to justify this machinery, but I could be wrong. I'd love to share some RUM data on this to help make a decision, but we don't track resource browser cache hits/misses, since getting that data from the browser is... unreliable at best 😕
In any case, if maintainers are happy with this approach as implemented, with the caveats we discussed, I think this could be a nice win for a small subset of users on concatenation-free environments, and I have no further comments.
Personally, I'm just not sure those visits are worth doing this, but since I lack the data to prove it, please take my opinion with a grain of salt 🙂
This ticket was mentioned in Slack in #core by westonruter. View the logs.
7 weeks ago
@westonruter commented on PR #13084:
7 weeks ago
#50
@sgomes:
If most pages share the same scripts, this raises the question of whether the optimisation is worth the effort. While faster is always better, all things being equal, things are not equal; this PR introduces a fair bit of extra code and complexity. This needs to be weighed against not just the performance gains (which you clearly laid out, and are compelling), but also against the likelihood of the optimisation being used at all.
I'm not sure I understand. There is an extremely high likelihood of the optimization being used. Since the render-blocking scripts and styles are shared across admin screens, optimizing for one CUJ will benefit the others.
In any case, if maintainers are happy with this approach as implemented, with the caveats we discussed, I think this could be a nice win for a small subset of users on concatenation-free environments, and I have no further comments.
I'm a maintainer and I'm happy with it 😄
The biggest win here for maintenance is eliminating load-scripts.php and load-styles.php and the associated concatenation logic which is way more complicated than the new prefetching logic being introduced here. The fact that prefetching the scripts and styles yields greater performance benefits than concatenation is also a huge win. It's a win-win!
I'm going move forward with committing.
Thanks again for the constructive feedback!
@sergiomdgomes commented on PR #13084:
7 weeks ago
#51
I'm not sure I understand. There is an extremely high likelihood of the optimization being used. Since the render-blocking scripts and styles are shared across admin screens, optimizing for one CUJ will benefit the others.
I meant how often the optimisation actually gets triggered and results in an improvement for a given user. In most cases, it will effectively be at most once per user, for users who blog or admin regularly — prefetching is only needed to populate the browser cache, and if the browser cache stays populated, there is no benefit to having it. Mobile might be a bit different there (smaller and more volatile caches, maybe?), but a big chunk of the market won't see the benefit because of lack of support in Safari.
So it seems to me the improvement is pretty situational, and my question was whether the infrequency of this improvement is worth the machinery that's being put in place.
In any case, I'll defer to your judgement on this 👍
@westonruter commented on PR #13084:
7 weeks ago
#52
@sgomes:
Mobile might be a bit different there (smaller and more volatile caches, maybe?), but a big chunk of the market won't see the benefit because of lack of support in Safari.
Actually, Safari is supported now thanks to a polyfill. See 89d909c32c3bf066a72230d86c2166dc7783d197.
@westonruter commented on PR #13084:
6 weeks ago
#53
Pushing up commits from rounds of high-effort reviews from Opus 5.5.
This ticket was mentioned in PR #14463 on WordPress/wordpress-develop by @westonruter.
4 weeks ago
#60
Retires script and style concatenation in the admin and on the login screen. Concatenation has been off by default since r64320, when the assets of the next admin screen also began to be prefetched (r64120). This removes the remaining code and deprecates what is left of its API.
WP_Scripts::do_item()andWP_Styles::do_item()print every item as its own tag. Inline scripts, inline styles and extra data always carry their sourceURL comment.- The
do_concat,print_html,concat,print_code,ext_handles,ext_versionanddefault_dirsproperties are deprecated, anddo_item()no longer checksdo_concat.WP_Scripts::in_default_dir(),WP_Styles::in_default_dir()andWP_Dependencies::get_etag()are deprecated. _print_scripts(),_print_styles()andscript_concat_settings()are deprecated and moved todeprecated.php. Theprint_head_scripts,print_footer_scripts,print_admin_stylesandprint_late_stylesfilters only decided whether concatenated or held markup was printed, so they are applied withapply_filters_deprecated()and no longer have an effect.wp_should_concatenate_admin_scripts()and its filter, added during this release cycle, are removed. TheCONCATENATE_SCRIPTSconstant is no longer read or listed in Site Health.wp-admin/load-scripts.phpandwp-admin/load-styles.phpare deprecated: they call_deprecated_file()and respond with 410 Gone.wp-admin/includes/noop.phpis deprecated and no longer defines its noop functions. PHPStan no longer excludes the three files.- Code written to run inside the loaders without WordPress loaded now uses the functions it avoided:
wp_get_wp_version(),str_contains(),get_theme_file_path()andis_rtl().
Backward compatibility notes for the dev note:
- About 110 plugins in the directory link to the loaders directly, such as Ad Inserter and Modula. Those requests now get a 410.
- Plugins that set
do_concatto hold markup inprint_htmlnow get the markup printed right away. Microthemer does this duringenqueue_block_assets. in_default_dir()is used as a check for core assets by Email Customizer and WP Scripts & Styles Optimizer. It still works, with a deprecation notice. Plugins that readdefault_dirs, such as WP Hide & Security Enhancer, keep working, since core still sets it.
This makes the following tickets obsolete: Core-65515, Core-15833, Core-36448, Core-36449, Core-52879, Core-45008, Core-63908, Core-47322, Core-36779, Core-43825 and Core-64087.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Implementation, tests, surveying related Trac tickets and plugin usage in the directory, and this description, all reviewed by @westonruter.
---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
🤖 Generated with Claude Code
#61
@
4 weeks ago
This is it! PR drafted to remove/deprecate concatenation: https://github.com/WordPress/wordpress-develop/pull/14463
@westonruter commented on PR #14463:
4 weeks ago
#62
Todo:
- [ ] Reach out to any theme/plugin directly setting
do_concat. - [ ] use a magic setter for
do_concatso we can fire doing it wrong.
@adamsilverstein commented on PR #14463:
4 weeks ago
#63
This looks great @westonruter - thanks for all your work here. I reviewed the code an there were no red flags, the changes made sense to me and your inline comments were helpful given my lack of familiarity with the scrip loader code this touches.
I did some smoke testing with a clean install and navigating around wp-admin I didn't notice any failed loads. I even tried out the customizer :).
I asked Claude for a review and the only points returned were backwards compatibility potential breaks I know you have already worked on weighing an mitigating so didn't seem worthwhile.
#65
follow-up:
↓ 66
@
4 weeks ago
@westonruter: Should the one-liners in load-styles.php and load-scripts.php be wrapped in JS/CSS comments /* ... */ just in case they are still loaded in <script> or <link> tags somewhere, and when the text/plain content type is maybe ignored/overwritten somehow?
#66
in reply to: ↑ 65
@
4 weeks ago
Replying to TobiasBg:
@westonruter: Should the one-liners in load-styles.php and load-scripts.php be wrapped in JS/CSS comments
/* ... */just in case they are still loaded in<script>or<link>tags somewhere, and when thetext/plaincontent type is maybe ignored/overwritten somehow?
Good question. I just tested and since load-scripts.php nd load-styles.php are returned with a 410 Gone status, a browser refuses to parse them. So the text/plain content type is just a bonus. There is no JavaScript syntax error appearing in the console, like:
Uncaught SyntaxError: Unexpected identifier 'are' (at load-scripts.php:1:9)
Since it doesn't try to evaluate this as JavaScript:
Scripts are no longer concatenated.
If the 410 Gone status wasn't sent, then browsers do try to run the JavaScript. But yeah, otherwise with 410 Gone, the only errors I see are in the Network log:
GET http://localhost:8000/wp-admin/load-styles.php net::ERR_ABORTED 410 (Gone)
GET http://localhost:8000/wp-admin/load-scripts.php net::ERR_ABORTED 410 (Gone)
And this is what we want.
#67
@
3 weeks ago
I started support forum topics with the ten plugins determined to have compatibility issues:
- Ad Inserter: Block Preview window broken
- Advanced iFrame: Area selector loses the admin styles
- CartFlows: Failed load-styles.php request on every admin screen
- Custom Block Builder - Lazy Blocks: Block builder code preview loses the admin styles
- Image Photo Gallery Final Tiles Grid: Classic Editor gallery dialog broken
- Modula Image Gallery: Classic Editor gallery dialog broken
- PMS Performance Lite: Script tag capture via cloned WP_Scripts returns empty string
- Social Login, Social Sharing by miniOrange: Profile completion page loses its styles
- UiPress lite: Admin toolbar unstyled on every admin screen
- WP Data Access: wpdadiehard shortcode loses its admin style
And I will add that this proposal will reduce the attack perimeter in terms of WordPress security.
Many security plugins propose to reinforce the parameters of calls to these 2 URLs, because possible source of DDOS attack.