I am working on optimizing my theme so that the load time can be decreased, as of now i have used wp_enqueue_script() to add my custom js file and everything is working fine as expected.

One thing which i am not very well aware of, the way plugin hook there js and css files. I want to force plugin to add there java-script files on the footer section of my theme, currently they are being loaded in the header section.

Can anyone help me to understand how this can be done (if possible).


The available input parameters of wp_enqueue_script() are:

<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>

where $in_footer is false by default. If you set it as true then the script will be placed into the footer, but you will need to have wp_footer() in your theme.

You should check out the Codex for more info:



Here is how it's done in the plugin JavaScript to Footer to move all the javascript files from the header to the footer:

remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
add_action('wp_footer', 'wp_print_scripts', 5);
add_action('wp_footer', 'wp_enqueue_scripts', 5);
add_action('wp_footer', 'wp_print_head_scripts', 5);

See the plugin source:


  • is there any way to load all scripts in the footer like wp_enqueue_script(true) and it should load everything in footer? Apr 4 '13 at 15:04
  • I updated the answer
    – birgire
    Apr 5 '13 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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