Marks the script module to be enqueued in the page.
Description
If a src is provided and the script module has not been registered yet, it will be registered.
Parameters
$idstring
The identifier of the script module. Should be unique. It will be used in the final import map.
$srcstringoptional
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: ''
$depsarrayoptional
List of dependencies. @type string|array ...$0 { An array of script module identifiers of the dependencies of this script module. The dependencies can be strings or arrays. If they are arrays, they need an id key with the script module identifier, and can contain an import key with either static or dynamic. By default, dependencies that don't contain an import key are considered static.Default: array()
$idstring
The script module identifier.
$importstring
Optional. Import type. May be either static or dynamic. Defaults to static. }
$versionstring|false|nulloptional
String specifying the script module version number. Defaults to false. 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.Default: false
$argsarrayoptional
An array of additional args. Default empty array.Default: array()
$in_footerbooldefault: 'false'. Optional
Whether to print the script module in the footer. Only relevant to block themes.
294publicfunctionenqueue(string$id,string$src='',array$deps=array(),$version=false,array$args=array()){295if(''===$id){296_doing_it_wrong(__METHOD__,__('Non-empty string required for id.'),'6.9.0');297return;298}299300if(!in_array($id,$this->queue,true)){301$this->queue[]=$id;302}303if(!isset($this->registered[$id])&&$src){304$this->register($id,$src,$deps,$version,$args);305}306}
History
Introduced in 6.5.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.9.7
Parameter $args added.verified against source
6.9.0
Added the $args parameter.from the docblock
6.5.0
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-script-modules.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.