From 178e6722fe65db62afa3e1bf71b15a99ddff30fa Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 13 Sep 2023 22:16:25 +0000 Subject: [PATCH] Bundled Themes: Ensure Twenty Twenty's main script loads in `head` for WP<6.3. Amends [56556]. Props westonruter, flixos90, peterwilsoncc. Fixes #59316. Built from https://develop.svn.wordpress.org/trunk@56569 git-svn-id: http://core.svn.wordpress.org/trunk@56081 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentytwenty/functions.php | 18 ++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/wp-content/themes/twentytwenty/functions.php b/wp-content/themes/twentytwenty/functions.php index 1ca2e4318a..d05df26a2b 100644 --- a/wp-content/themes/twentytwenty/functions.php +++ b/wp-content/themes/twentytwenty/functions.php @@ -215,16 +215,14 @@ function twentytwenty_register_scripts() { wp_enqueue_script( 'comment-reply' ); } - wp_enqueue_script( - 'twentytwenty-js', - get_template_directory_uri() . '/assets/js/index.js', - array(), - $theme_version, - array( - 'in_footer' => false, // Because involves header. - 'strategy' => 'defer', - ) - ); + /* + * This script is intentionally printed in the head because it involves the page header. The `defer` script loading + * strategy ensures that it does not block rendering; being in the head it will start loading earlier so that it + * will execute sooner once the DOM has loaded. The $args array is not used here to avoid unintentional footer + * placement in WP<6.3; the wp_script_add_data() call is used instead. + */ + wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version ); + wp_script_add_data( 'twentytwenty-js', 'strategy', 'defer' ); } add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' ); diff --git a/wp-includes/version.php b/wp-includes/version.php index d38f8034d6..d69173e34b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56568'; +$wp_version = '6.4-alpha-56569'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.