Skip to content

Commit e2d4676

Browse files
committed
Explicitly set a11y module to have fetchpriority=low
1 parent 0222ca9 commit e2d4676

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/wp-includes/script-modules.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,21 @@ function wp_default_script_modules() {
181181
break;
182182
}
183183

184-
// The Interactivity API is designed with server-side rendering as its primary goal, so all of its script modules should be loaded with low fetch priority since they should not be needed in the critical rendering path.
184+
/*
185+
* The Interactivity API is designed with server-side rendering as its primary goal, so all of its script modules
186+
* should be loaded with low fetchpriority since they should not be needed in the critical rendering path.
187+
* Also, the @wordpress/a11y script module is intended to be used as a dynamic import dependency, in which case
188+
* the fetchpriority is irrelevant. See <https://make.wordpress.org/core/2024/10/14/updates-to-script-modules-in-6-7/>.
189+
* However, in case it is added as a static import dependency, the fetchpriority is explicitly set to be 'low'
190+
* since the module should not be involved in the critical rendering path, and if it is, its fetchpriority will
191+
* be bumped to match the fetchpriority of the dependent script.
192+
*/
185193
$args = array();
186-
if ( str_starts_with( $script_module_id, '@wordpress/interactivity' ) || str_starts_with( $script_module_id, '@wordpress/block-library' ) ) {
194+
if (
195+
str_starts_with( $script_module_id, '@wordpress/interactivity' ) ||
196+
str_starts_with( $script_module_id, '@wordpress/block-library' ) ||
197+
'@wordpress/a11y' === $script_module_id
198+
) {
187199
$args['fetchpriority'] = 'low';
188200
}
189201

0 commit comments

Comments
 (0)