You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Script Loader: Propagate fetchpriority from dependents to dependencies.
This introduces a "fetchpriority bumping" mechanism for both classic scripts (`WP_Scripts`) and script modules (`WP_Script_Modules`). When a script with a higher `fetchpriority` is enqueued, any of its dependencies will have their `fetchpriority` elevated to match that of the highest-priority dependent. This ensures that all assets in a critical dependency chain are loaded with the appropriate priority, preventing a high-priority script from being blocked by a low-priority dependency. This is similar to logic used in script loading strategies to ensure that a blocking dependent causes delayed (`async`/`defer`) dependencies to also become blocking. See #12009.
When a script's `fetchpriority` is escalated, its original, registered priority is added to the tag via a `data-wp-fetchpriority` attribute. This matches the addition of the `data-wp-strategy` parameter added when the resulting loading strategy does not match the original.
Developed in WordPress/wordpress-develop#9770.
Follow-up to [60704].
Props westonruter, jonsurrell.
Fixes #61734.
Built from https://develop.svn.wordpress.org/trunk@60931
git-svn-id: http://core.svn.wordpress.org/trunk@60267 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Copy file name to clipboardExpand all lines: wp-includes/script-modules.php
+14-2Lines changed: 14 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -181,9 +181,21 @@ function wp_default_script_modules() {
181
181
break;
182
182
}
183
183
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.
0 commit comments