Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

Choose a reason for hiding this comment

The 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 👍

Copy link
Member Author

Choose a reason for hiding this comment

The 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 func_get_args().

}
}
remove_action( 'wp_default_scripts', 'wp_default_script_modules' );
Expand Down
Loading