From 88a4cf17a617134bd91cc5fa8571eac0a7c6fede Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 28 Jun 2023 14:16:27 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@56092 git-svn-id: http://core.svn.wordpress.org/trunk@55604 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-scripts.php | 14 ++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-scripts.php b/wp-includes/class-wp-scripts.php index 857f1e948b..0c85201bad 100644 --- a/wp-includes/class-wp-scripts.php +++ b/wp-includes/class-wp-scripts.php @@ -907,9 +907,19 @@ JS; * @return string The best eligible loading strategy. */ private function get_eligible_loading_strategy( $handle ) { - $eligible = $this->filter_eligible_strategies( $handle ); + $intended = (string) $this->get_data( $handle, 'strategy' ); - // Bail early once we know the eligible strategy is blocking. + // Bail early if there is no intended strategy. + if ( ! $intended ) { + return ''; + } + + // If the intended strategy is 'defer', limit the initial list of eligibles. + $initial = ( 'defer' === $intended ) ? array( 'defer' ) : null; + + $eligible = $this->filter_eligible_strategies( $handle, $initial ); + + // Return early once we know the eligible strategy is blocking. if ( empty( $eligible ) ) { return ''; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 85fbeee08f..0c9ed48785 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-56091'; +$wp_version = '6.3-alpha-56092'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.