Make WordPress Core


Ignore:
Timestamp:
10/19/2026 10:45:25 PM (19 hours ago)
Author:
westonruter
Message:

Script Loader: Retire script and style concatenation.

Scripts and styles in the admin and on the login screen are no longer concatenated through load-scripts.php and load-styles.php. Concatenation paid off when browsers opened few connections per host over HTTP/1.1, but it has long been a source of bugs: dependencies outside the default directories were not honored, SCRIPT_DEBUG and the script_loader_src and style_loader_src filters were ignored, inline styles could be duplicated, and code run by the loaders without WordPress loaded caused fatal errors. It was turned off by default in r64320, once the assets of the next admin screen began to be prefetched in r64120, and this removes what remains.

Every item is now printed as its own tag, and what remains of the concatenation API is deprecated or removed:

  • The properties of WP_Scripts and WP_Styles that held items back for concatenation are deprecated but still declared, so plugins reading or setting them keep working. The do_item() methods no longer check do_concat.
  • The _print_scripts(), _print_styles(), script_concat_settings(), in_default_dir() and WP_Dependencies::get_etag() functions are deprecated.
  • The print_head_scripts, print_footer_scripts, print_admin_styles and print_late_styles filters only decided whether held markup was printed, so they are applied with apply_filters_deprecated() and their return values are ignored.
  • The CONCATENATE_SCRIPTS constant is no longer read.
  • The wp_should_concatenate_admin_scripts() function and its filter, added in r64120 for the transition and never released, are removed.

The loaders now respond with 410 Gone and a one-line plain text explanation, without loading WordPress, so that requests from bots and stale links cost next to nothing. Code written to run inside them without WordPress loaded, such as wp_theme_has_theme_json(), now uses the functions it had avoided, and wp-admin/includes/noop.php no longer defines its stub functions.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/14463.
Follow-up to r10357, r43580, r60719, r62657, r64120, r64320, r64485.

Props westonruter, jonsurrell, peterwilsoncc, azaozz, markhowellsmead, sergiomdgomes, jerclarke, adamsilverstein, sukhendu2002, adnan007, momo360modena, desrosj, welcher.
See #15833, #36448, #36449, #36779, #43825, #45008, #47322, #52879, #63908, #64087, #65515.
Fixes #57548.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r64489 r64585  
    66036603
    66046604/**
     6605 * Determines the concatenation settings for scripts and styles.
     6606 *
     6607 * Scripts and styles are no longer concatenated, so this only gives the `$concatenate_scripts`,
     6608 * `$compress_scripts`, and `$compress_css` globals a value of false when they are not already set,
     6609 * for code that still reads them.
     6610 *
     6611 * @since 2.8.0
     6612 * @since 7.2.0 The `$compress_scripts` and `$compress_css` globals default to false, as PHP compression
     6613 *              of scripts and styles was removed in 4.9.9.
     6614 * @deprecated 7.2.0 Scripts and styles are no longer concatenated.
     6615 *
     6616 * @global bool $concatenate_scripts
     6617 * @global bool $compress_scripts
     6618 * @global bool $compress_css
     6619 */
     6620function script_concat_settings(): void {
     6621        global $concatenate_scripts, $compress_scripts, $compress_css;
     6622
     6623        _deprecated_function( __FUNCTION__, '7.2.0' );
     6624
     6625        if ( ! isset( $concatenate_scripts ) ) {
     6626                $concatenate_scripts = false;
     6627        }
     6628
     6629        if ( ! isset( $compress_scripts ) ) {
     6630                $compress_scripts = false;
     6631        }
     6632
     6633        if ( ! isset( $compress_css ) ) {
     6634                $compress_css = false;
     6635        }
     6636}
     6637
     6638/**
     6639 * Prints scripts (internal use only)
     6640 *
     6641 * @since 2.8.0
     6642 * @deprecated 7.2.0 Scripts are no longer concatenated.
     6643 *
     6644 * @ignore
     6645 *
     6646 * @global WP_Scripts $wp_scripts
     6647 */
     6648function _print_scripts(): void {
     6649        global $wp_scripts;
     6650
     6651        _deprecated_function( __FUNCTION__, '7.2.0' );
     6652
     6653        if ( ! empty( $wp_scripts->print_html ) ) {
     6654                echo $wp_scripts->print_html;
     6655        }
     6656}
     6657
     6658/**
     6659 * Prints styles (internal use only).
     6660 *
     6661 * @ignore
     6662 * @since 3.3.0
     6663 * @deprecated 7.2.0 Styles are no longer concatenated.
     6664 */
     6665function _print_styles(): void {
     6666        _deprecated_function( __FUNCTION__, '7.2.0' );
     6667
     6668        $wp_styles = wp_styles();
     6669
     6670        if ( ! empty( $wp_styles->print_html ) ) {
     6671                echo $wp_styles->print_html;
     6672        }
     6673}
     6674
     6675/**
    66056676 * Starts an output buffer that sends the Document-Isolation-Policy header
    66066677 * and adds crossorigin="anonymous" to cross-origin resources.
Note: See TracChangeset for help on using the changeset viewer.