wp_register_script() – Registers a new script.

You appear to be a bot. Output may be restricted


Registers a new script.

Registers a script to be enqueued later using the wp_enqueue_script() function.


$bool = wp_register_script( $handle, $src, $deps, $ver, $args );


( string ) required – Name of the script. Should be unique.
( string|false ) required – Full URL of the script, or path of the script relative to the WordPress root directory. If source is set to false, script is an alias of other scripts it depends on.
( string[] ) optional – Optional. An array of registered script handles this script depends on. Default empty array.
( 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.
( array|bool ) optional – { Optional. An array of additional script loading strategies. Default empty array. Otherwise, it may be a boolean in which case it determines whether the script is printed in the footer. Default false.
( string ) optional – Optional. If provided, may be either 'defer' or 'async'.
( bool ) optional – Optional. Whether to print the script in the footer. Default 'false'. }


bool Whether the script has been registered. True on success, false on failure.


File name: wordpress/wp-includes/functions.wp-scripts.php


1 to 20 of 20
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $args = array() ) {
  if ( ! is_array( $args ) ) {
    $args = array(
      'in_footer' => (bool) $args,
  _wp_scripts_maybe_doing_it_wrong( wp_register_script, $handle );

  $wp_scripts = wp_scripts();

  $registered = $wp_scripts->add( $handle, $src, $deps, $ver );
  if ( ! empty( $args['in_footer'] ) ) {
    $wp_scripts->add_data( $handle, 'group', 1 );
  if ( ! empty( $args['strategy'] ) ) {
    $wp_scripts->add_data( $handle, 'strategy', $args['strategy'] );
  return $registered;

 View on GitHub View on Trac