WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I wanted to put the scripts that all my plugins use at the end of the page, where would I do this? Using YSlow/Firebug it recommends this tactic.

share|improve this question
up vote 0 down vote accepted

The hook for registering the script in the footer is:

function my_init_method() {
    wp_register_script( 'myscript', 'http://www.mydomain.com/js/myscript.js','','','true');
    wp_enqueue_script( 'jquery' );

add_action('init', 'my_init_method');

be sure to look at this and this, both are important.

share|improve this answer
Probably enqueue myscript and not jquery. Also I'd pass array(), null rather than '', '' in parameters there. It doesn't expect string for first and null for second will suppress version tag (relatively recent improvement). – Rarst Mar 14 '11 at 23:14
yes. I should had thought about it. – Asaf Chertkoff Mar 15 '11 at 7:06
I've tested this with one plugin so far. Looks good, thanks. Will try and get them all done at some point! – JohnnyBizzle Mar 17 '11 at 11:29

One way - make use of queue. wp_register_script() accepts parameter that bumps queued scripts to footer. The issue is that not all plugins use queue (they really should) and many that do don't bother to target footer. So you will need to hook and do a lot of registrations and re-registrations.

Another way is using good caching plugin (like W3 Total Cache) that is capable of moving and even concatenating scripts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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