function wp_register_script( $handle, $src, $deps = array() {}

Register new Javascript file.


  • string $handle: Script name
  • string $src: Script url
  • array $deps: (optional) Array of script names on which this script depends
  • string|bool $ver: (optional) Script version (used for cache busting), set to NULL to disable
  • bool $in_footer: (optional) Whether to enqueue the script before </head> or before </body>

Source code

function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {

	global $wp_scripts;

	if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {

		if ( ! did_action( 'init' ) )

			_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),

				'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );

		$wp_scripts = new WP_Scripts();


	$wp_scripts->add( $handle, $src, $deps, $ver );

	if ( $in_footer )

		$wp_scripts->add_data( $handle, 'group', 1 );



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: