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:where
$in_footer
isfalse
by default. If you set it astrue
then the script will be placed into the footer, but you will need to havewp_footer()
in your theme.You should check out the Codex for more info:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
Update:
Here is how it’s done in the plugin JavaScript to Footer to move all the javascript files from the header to the footer:
See the plugin source:
http://plugins.svn.wordpress.org/footer-javascript/trunk/footer-javascript.php