Make WordPress Core


Ignore:
Timestamp:
06/28/2023 02:14:58 PM (10 months ago)
Author:
azaozz
Message:

Script Loader: Fix unintended adding of async to scripts that are printed directly with wp_print_scripts() without enqueueing them beforehand.

Props: joemcgill, westonruter, felixarntz, peterwilsoncc.
See: #58648.

File:
1 edited

Legend:

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

    r56033 r56092  
    908908     */
    909909    private function get_eligible_loading_strategy( $handle ) {
    910         $eligible = $this->filter_eligible_strategies( $handle );
    911 
    912         // Bail early once we know the eligible strategy is blocking.
     910        $intended = (string) $this->get_data( $handle, 'strategy' );
     911
     912        // Bail early if there is no intended strategy.
     913        if ( ! $intended ) {
     914            return '';
     915        }
     916
     917        // If the intended strategy is 'defer', limit the initial list of eligibles.
     918        $initial = ( 'defer' === $intended ) ? array( 'defer' ) : null;
     919
     920        $eligible = $this->filter_eligible_strategies( $handle, $initial );
     921
     922        // Return early once we know the eligible strategy is blocking.
    913923        if ( empty( $eligible ) ) {
    914924            return '';
Note: See TracChangeset for help on using the changeset viewer.