wp_enqueue_script() – Enqueue a script.
You appear to be a bot. Output may be restricted
Description
Enqueue a script.
Registers the script if $src provided (does NOT overwrite), and enqueues it.
Usage
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
Parameters
- $handle
- ( string ) required – Name of the script. Should be unique.
- $src
- ( string ) optional – Full URL of the script, or path of the script relative to the WordPress root directory. Default empty.
- $deps
- ( string[] ) optional – Optional. An array of registered script handles this script depends on. Default empty array.
- $ver
- ( string|bool|null ) optional – Optional. String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
- $in_footer
- ( bool ) optional – Optional. Whether to enqueue the script before
</body>
instead of in the `<head>`. Default 'false'.
Returns
void
Source
File name: wordpress/wp-includes/functions.wp-scripts.php
Lines:
1 to 19 of 19
function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false ) { _wp_scripts_maybe_doing_it_wrong( wp_enqueue_script, $handle ); $wp_scripts = wp_scripts(); if ( $src || $in_footer ) { $_handle = explode( '?', $handle ); if ( $src ) { $wp_scripts->add( $_handle[0], $src, $deps, $ver ); } if ( $in_footer ) { $wp_scripts->add_data( $_handle[0], 'group', 1 ); } } $wp_scripts->enqueue( $handle ); }