wp_enqueue_script_module()
Marks the script module to be enqueued in the page.
If a src is provided and the script module has not been registered yet, it will be registered.
No Hooks.
Returns
null. Nothing (null).
Usage
wp_enqueue_script_module( $id, $src, $deps, $version, $args );
- $id(string) (required)
- The identifier of the script module. Should be unique. It will be used in the final import map.
- $src(string)
- Full URL of the script module, or path of the script module relative to the WordPress root directory. If it is provided and the script module has not been registered yet, it will be registered.
Default:'' - $deps(array)
- .
Default:array() - $version(string|false|null)
- String specifying the script module version number. It is added to the URL as a query string for cache busting purposes. If
$versionis set to false, the version number is the currently installed WordPress version. If$versionis set to null, no version is added.
Default:false - $args(array)
- .
Default:array()
Changelog
| Since 6.5.0 | Introduced. |
| Since 6.9.0 | Added the $args parameter. |
wp_enqueue_script_module() wp enqueue script module code WP 7.0
function wp_enqueue_script_module( string $id, string $src = '', array $deps = array(), $version = false, array $args = array() ) {
wp_script_modules()->enqueue( $id, $src, $deps, $version, $args );
}