<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56556] trunk/src/wp-content/themes: Bundled Themes: Use `defer` loading strategy for theme scripts.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56556">56556</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56556","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-09-12 00:04:15 +0000 (Tue, 12 Sep 2023)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Bundled Themes: Use `defer` loading strategy for theme scripts.

* Add `defer` loading strategy for all frontend end-user theme scripts (excluding Customizer preview).
* Move scripts to the `head` which relate to the initial page viewport to ensure they start loading earlier and execute sooner while still not blocking rendering.
* Update Twenty Twenty's script loader (`TwentyTwenty_Script_Loader`) to support core's built-in script loading strategies (<a href="https://core.trac.wordpress.org/ticket/12009">#12009</a>), while also retaining backwards-compatibility for child themes that may set `async` and `defer` script data.
* Update the main script loading strategy in Twenty Twenty from `async` to `defer` for better performance on repeat page views, since when an `async` script is cached it will block rendering.

Props westonruter, flixos90, sabernhardt.
Fixes <a href="https://core.trac.wordpress.org/ticket/59316">#59316</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpcontentthemestwentyelevenshowcasephp">trunk/src/wp-content/themes/twentyeleven/showcase.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyfifteenfunctionsphp">trunk/src/wp-content/themes/twentyfifteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyfourteenfunctionsphp">trunk/src/wp-content/themes/twentyfourteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentynineteenfunctionsphp">trunk/src/wp-content/themes/twentynineteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentyseventeenfunctionsphp">trunk/src/wp-content/themes/twentyseventeen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentysixteenfunctionsphp">trunk/src/wp-content/themes/twentysixteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentythirteenfunctionsphp">trunk/src/wp-content/themes/twentythirteen/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentytwelvefunctionsphp">trunk/src/wp-content/themes/twentytwelve/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentytwentyclassesclasstwentytwentyscriptloaderphp">trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentytwentyfunctionsphp">trunk/src/wp-content/themes/twentytwenty/functions.php</a></li>
<li><a href="#trunksrcwpcontentthemestwentytwentyonefunctionsphp">trunk/src/wp-content/themes/twentytwentyone/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpcontentthemestwentyelevenshowcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyeleven/showcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyeleven/showcase.php     2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentyeleven/showcase.php       2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,7 +16,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Enqueue showcase script for the slider.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '20211130' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+wp_enqueue_script(
+       'twentyeleven-showcase',
+       get_template_directory_uri() . '/js/showcase.js',
+       array( 'jquery' ),
+       '20211130',
+       array(
+               'in_footer' => false, // Because involves header.
+               'strategy'  => 'defer',
+       )
+);
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> get_header(); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyfifteenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyfifteen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyfifteen/functions.php   2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentyfifteen/functions.php     2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -454,7 +454,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_script( 'twentyfifteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20141210' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20221101', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentyfifteen-script',
+               get_template_directory_uri() . '/js/functions.js',
+               array( 'jquery' ),
+               '20221101',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px">         wp_localize_script(
</span><span class="cx" style="display: block; padding: 0 10px">                'twentyfifteen-script',
</span><span class="cx" style="display: block; padding: 0 10px">                'screenReaderText',
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyfourteenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyfourteen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyfourteen/functions.php  2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentyfourteen/functions.php    2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,7 +367,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( is_front_page() && 'slider' === get_theme_mod( 'featured_content_layout' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_enqueue_script( 'twentyfourteen-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20150120', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_enqueue_script(
+                       'twentyfourteen-slider',
+                       get_template_directory_uri() . '/js/slider.js',
+                       array( 'jquery' ),
+                       '20150120',
+                       array(
+                               'in_footer' => false, // Because involves header.
+                               'strategy'  => 'defer',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">                 wp_localize_script(
</span><span class="cx" style="display: block; padding: 0 10px">                        'twentyfourteen-slider',
</span><span class="cx" style="display: block; padding: 0 10px">                        'featuredSliderDefaults',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -378,7 +387,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentyfourteen-script',
+               get_template_directory_uri() . '/js/functions.js',
+               array( 'jquery' ),
+               '20230526',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentynineteenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentynineteen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentynineteen/functions.php  2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentynineteen/functions.php    2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -258,8 +258,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">        wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( has_nav_menu( 'menu-1' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '20200129', array( 'in_footer' => true ) );
-               wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '20230621', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_enqueue_script(
+                       'twentynineteen-priority-menu',
+                       get_theme_file_uri( '/js/priority-menu.js' ),
+                       array(),
+                       '20200129',
+                       array(
+                               'in_footer' => false, // Because involves header.
+                               'strategy'  => 'defer',
+                       )
+               );
+               wp_enqueue_script(
+                       'twentynineteen-touch-navigation',
+                       get_theme_file_uri( '/js/touch-keyboard-navigation.js' ),
+                       array(),
+                       '20230621',
+                       array(
+                               'in_footer' => true,
+                               'strategy'  => 'defer',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentyseventeenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentyseventeen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentyseventeen/functions.php 2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentyseventeen/functions.php   2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -479,7 +479,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        // Skip-link fix is no longer enqueued by default.
</span><span class="cx" style="display: block; padding: 0 10px">        wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', array( 'in_footer' => true ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentyseventeen-global',
+               get_theme_file_uri( '/assets/js/global.js' ),
+               array( 'jquery' ),
+               '20211130',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $twentyseventeen_l10n = array(
</span><span class="cx" style="display: block; padding: 0 10px">                'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -486,7 +495,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( has_nav_menu( 'top' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                wp_enqueue_script( 'twentyseventeen-navigation', get_theme_file_uri( '/assets/js/navigation.js' ), array( 'jquery' ), '20210122', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_enqueue_script(
+                       'twentyseventeen-navigation',
+                       get_theme_file_uri( '/assets/js/navigation.js' ),
+                       array( 'jquery' ),
+                       '20210122',
+                       array(
+                               'in_footer' => false, // Because involves header.
+                               'strategy'  => 'defer',
+                       )
+               );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $twentyseventeen_l10n['expand']   = __( 'Expand child menu', 'twentyseventeen' );
</span><span class="cx" style="display: block; padding: 0 10px">                $twentyseventeen_l10n['collapse'] = __( 'Collapse child menu', 'twentyseventeen' );
</span><span class="cx" style="display: block; padding: 0 10px">                $twentyseventeen_l10n['icon']     = twentyseventeen_get_svg(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -499,7 +517,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'jquery-scrollto',
+               get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ),
+               array( 'jquery' ),
+               '2.1.3',
+               array(
+                       'in_footer' => true,
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_script( 'comment-reply' );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentysixteenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentysixteen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentysixteen/functions.php   2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentysixteen/functions.php     2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,7 +423,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_script( 'twentysixteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20170530' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230629', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentysixteen-script',
+               get_template_directory_uri() . '/js/functions.js',
+               array( 'jquery' ),
+               '20230629',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        wp_localize_script(
</span><span class="cx" style="display: block; padding: 0 10px">                'twentysixteen-script',
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentythirteenfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentythirteen/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentythirteen/functions.php  2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentythirteen/functions.php    2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -321,7 +321,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Loads JavaScript file with functionality specific to Twenty Thirteen.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentythirteen-script',
+               get_template_directory_uri() . '/js/functions.js',
+               array( 'jquery' ),
+               '20230526',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
</span><span class="cx" style="display: block; padding: 0 10px">        $font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentytwelvefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentytwelve/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentytwelve/functions.php    2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentytwelve/functions.php      2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,7 +188,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        // Adds JavaScript for handling the navigation menu hide-and-show behavior.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'jquery' ), '20141205', array( 'in_footer' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_enqueue_script(
+               'twentytwelve-navigation',
+               get_template_directory_uri() . '/js/navigation.js',
+               array( 'jquery' ),
+               '20141205',
+               array(
+                       'in_footer' => false, // Because involves header.
+                       'strategy'  => 'defer',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $font_url = twentytwelve_get_font_url();
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! empty( $font_url ) ) {
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentytwentyclassesclasstwentytwentyscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php     2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php       2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,9 +20,31 @@
</span><span class="cx" style="display: block; padding: 0 10px">        class TwentyTwenty_Script_Loader {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 * Migrates legacy async/defer script data which might be used by child themes.
+                *
+                * This method is used on the `print_scripts_array` filter.
+                *
+                * @since Twenty Twenty 2.0
+                *
+                * @param string[] $to_do An array of script dependency handles.
+                * @return string[] Unchanged array of script dependency handles.
+                */
+               public function migrate_legacy_strategy_script_data( $to_do ) {
+                       foreach ( $to_do as $handle ) {
+                               foreach ( array( 'async', 'defer' ) as $strategy ) {
+                                       if ( wp_scripts()->get_data( $handle, $strategy ) ) {
+                                               wp_script_add_data( $handle, 'strategy', $strategy );
+                                       }
+                               }
+                       }
+                       return $to_do;
+               }
+
+               /**
</ins><span class="cx" style="display: block; padding: 0 10px">                  * Adds async/defer attributes to enqueued / registered scripts.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * If #12009 lands in WordPress, this function can no-op since it would be handled in core.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * Now that #12009 has landed in WordPress 6.3, this method is only used for older versions of WordPress.
+                * This method is used on the `script_loader_tag` filter.
</ins><span class="cx" style="display: block; padding: 0 10px">                  *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @since Twenty Twenty 1.0
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -33,10 +55,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * @return string Script HTML string.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                public function filter_script_loader_tag( $tag, $handle ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        foreach ( array( 'async', 'defer' ) as $attr ) {
-                               if ( ! wp_scripts()->get_data( $handle, $attr ) ) {
-                                       continue;
-                               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 $strategies = array(
+                               'async' => (bool) wp_scripts()->get_data( $handle, 'async' ),
+                               'defer' => (bool) wp_scripts()->get_data( $handle, 'defer' ),
+                       );
+                       $strategy   = wp_scripts()->get_data( $handle, 'strategy' );
+                       if ( $strategy && isset( $strategies[ $strategy ] ) ) {
+                               $strategies[ $strategy ] = true;
+                       }
+
+                       foreach ( array_keys( array_filter( $strategies ) ) as $attr ) {
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 // Prevent adding attribute when already added in #12009.
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( ! preg_match( ":\s$attr(=|>|\s):", $tag ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                        $tag = preg_replace( ':(?=></script>):', " $attr", $tag, 1 );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentytwentyfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentytwenty/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentytwenty/functions.php    2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentytwenty/functions.php      2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -135,7 +135,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * by the theme.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        $loader = new TwentyTwenty_Script_Loader();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( version_compare( $GLOBALS['wp_version'], '6.3', '<' ) ) {
+               add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
+       } else {
+               add_filter( 'print_scripts_array', array( $loader, 'migrate_legacy_strategy_script_data' ), 100 );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'after_setup_theme', 'twentytwenty_theme_support' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,8 +215,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                wp_enqueue_script( 'comment-reply' );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp_enqueue_script( 'twentytwenty-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version );
-       wp_script_add_data( 'twentytwenty-js', 'async', true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 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',
+               )
+       );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' );
</span></span></pre></div>
<a id="trunksrcwpcontentthemestwentytwentyonefunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-content/themes/twentytwentyone/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-content/themes/twentytwentyone/functions.php 2023-09-11 11:35:59 UTC (rev 56555)
+++ trunk/src/wp-content/themes/twentytwentyone/functions.php   2023-09-12 00:04:15 UTC (rev 56556)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -449,7 +449,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        get_template_directory_uri() . '/assets/js/primary-navigation.js',
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 'twenty-twenty-one-ie11-polyfills' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        wp_get_theme()->get( 'Version' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        array( 'in_footer' => true )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 array(
+                               'in_footer' => false, // Because involves header.
+                               'strategy'  => 'defer',
+                       )
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre>
</div>
</div>

</body>
</html>