wp_enqueue_script_module()WP 6.5.0

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.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wp_enqueue_script_module( $id, $src, $deps, $version, $args );
$id(строка) (обязательный)
The identifier of the script module. Should be unique. It will be used in the final import map.
$src(строка)
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.
По умолчанию: ''
$deps(массив)
.
По умолчанию: array()
$version(строка|false|null)
String specifying the script module version number. It is added to the URL as a query string for cache busting purposes. If $version is set to false, the version number is the currently installed WordPress version. If $version is set to null, no version is added.
По умолчанию: false
$args(array<string, string|bool>)

An array of additional args.

По умолчанию: empty array

  • in_footer(true|false)
    Whether to print the script module in the footer. Only relevant to block themes. Optional.
    По умолчанию: 'false'

  • fetchpriority('auto'|'low'|'high')
    Fetch priority. Optional.
    По умолчанию: 'auto'

Список изменений

С версии 6.5.0 Введена.
С версии 6.9.0 Added the $args parameter.

Код wp_enqueue_script_module() WP 7.1

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 );
}