Changeset 60704 for trunk/src/wp-includes/script-modules.php
- Timestamp:
- 09/03/2025 10:15:31 PM (5 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/script-modules.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-modules.php
r59223 r60704 36 36 * 37 37 * @since 6.5.0 38 * @since 6.9.0 Added the $args parameter. 38 39 * 39 40 * @param string $id The identifier of the script module. Should be unique. It will be used in the … … 61 62 * is set to false, the version number is the currently installed WordPress version. 62 63 * If $version is set to null, no version is added. 64 * @param array $args { 65 * Optional. An array of additional args. Default empty array. 66 * 67 * @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional. 68 * } 63 69 */ 64 function wp_register_script_module( string $id, string $src, array $deps = array(), $version = false ) {65 wp_script_modules()->register( $id, $src, $deps, $version );70 function wp_register_script_module( string $id, string $src, array $deps = array(), $version = false, array $args = array() ) { 71 wp_script_modules()->register( $id, $src, $deps, $version, $args ); 66 72 } 67 73 … … 73 79 * 74 80 * @since 6.5.0 81 * @since 6.9.0 Added the $args parameter. 75 82 * 76 83 * @param string $id The identifier of the script module. Should be unique. It will be used in the … … 98 105 * is set to false, the version number is the currently installed WordPress version. 99 106 * If $version is set to null, no version is added. 107 * @param array $args { 108 * Optional. An array of additional args. Default empty array. 109 * 110 * @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional. 111 * } 100 112 */ 101 function wp_enqueue_script_module( string $id, string $src = '', array $deps = array(), $version = false ) {102 wp_script_modules()->enqueue( $id, $src, $deps, $version );113 function wp_enqueue_script_module( string $id, string $src = '', array $deps = array(), $version = false, array $args = array() ) { 114 wp_script_modules()->enqueue( $id, $src, $deps, $version, $args ); 103 115 } 104 116 … … 170 182 } 171 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. 185 $args = array(); 186 if ( str_starts_with( $script_module_id, '@wordpress/interactivity' ) || str_starts_with( $script_module_id, '@wordpress/block-library' ) ) { 187 $args['fetchpriority'] = 'low'; 188 } 189 172 190 $path = includes_url( "js/dist/script-modules/{$file_name}" ); 173 wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'] );191 wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'], $args ); 174 192 } 175 193 }
Note: See TracChangeset
for help on using the changeset viewer.