I have some scripts that I'm enqueueing like this:

wp_enqueue_script("myscript" , get_template_directory_uri()."/js/myscript.js", Array('myscript'), " ");

I want to enqueue them in the footer, which means I should use the last parameter of wp_enqueue_script(), but I don't always want to pass the other params.

wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer);

How do I get to $in_footer without messing up the default params in between it and $handle? Can I just put empty strings for each?

1 Answer 1


Try passing array() for $deps, and NULL for $ver:

wp_enqueue_script( $handle, $src, array(), NULL, $in_footer);

Or, using your function call:

wp_enqueue_script("myscript" , get_template_directory_uri()."/js/myscript.js", array(), NULL, true );

By the way, passing the script itself as a dependency to itself will probably make something blow up.

Note also: if your script depends on jQuery, just pass jQuery as a dependency, instead of enqueueing it separately:

wp_enqueue_script("myscript" , get_template_directory_uri()."/js/myscript.js", array( 'jquery' ), NULL, true );
  • Thanks--didn't actually mean to put myscript as a dependancy of itself--I was just simplifying the longer scripts there and didnt' notice I gave it the same name. Commented Jan 22, 2013 at 19:44
  • 1
    Related question, if you care to follow up: wordpress.stackexchange.com/questions/82668/… Commented Jan 22, 2013 at 19:49
  • Actually--one question. You put the second parameter ($src) in there. But what if I already registered the script and don't want the source again? Commented Jan 22, 2013 at 20:36
  • If you already registered the script, then all of the parameters would go in your wp_register_script() call, and your wp_enqueue_script() call would simply include the script name: wp_enqueue_script( 'myscript' ). Commented Jan 22, 2013 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.