-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add fetchpriority=low support to script modules #70173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
69fe993
e2650be
e2828a7
6c38110
3cc250e
2e10eb3
1ab3c34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -653,8 +653,14 @@ function gutenberg_default_script_modules() { | |
| break; | ||
| } | ||
|
|
||
| // All script modules in Gutenberg are (currently) related to the Interactivity API which prioritizes server-side rendering. | ||
| // Therefore, the modules should be fetched with a low priority to avoid network contention with any LCP element resource. | ||
| $args = array( | ||
| 'fetchpriority' => 'low', | ||
| ); | ||
|
|
||
| $path = gutenberg_url( "build-module/{$file_name}" ); | ||
| wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'] ); | ||
| wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'], $args ); // The $args parameter is new as of WP 6.9 per <https://core.trac.wordpress.org/ticket/61734>. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked to make sure extra arguments to functions don't cause errors/warnings/notices and that does seem to be the case 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, adding extra arguments is fine. No complaints going back even to PHP 4.3: https://3v4l.org/doYun Any additional unnamed params could be obtained by the function via |
||
| } | ||
| } | ||
| remove_action( 'wp_default_scripts', 'wp_default_script_modules' ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.