When running a Yslow test on your WordPress site, you’ll notice one of the performance score about putting your Javascript at bottom. Why should javascript be put in footer you might ask? According to yahoo developer, it is one of best practice rule for speeding up your website.

WordPress wp_enqueue_script() usage

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

Themes developer commonly use WordPress wp_enqueue_script() in their theme’s functions like this

wp_enqueue_script('html5shim', '//html5shiv.googlecode.com/svn/trunk/html5.js', array('jquery'), '1.1' );

but this code always put the scripts before end </head> and not in the footer.

In this post, you’ll learn how to use wp_enqueue_script() in WordPress Footer. Just edit your current wp_enqueue_script() like above code to new code like this:

wp_enqueue_script('html5shim', '//html5shiv.googlecode.com/svn/trunk/html5.js', false, '1.1', true );

as you can see the code are much different than the first one. i removed the array(‘jquery’) handler and set $in_footer to ‘true’.

With this edits, your javascript should be properly enqueue in your WordPress theme footer with the exception of WordPress default jQuery.

Related Articles:

Website Development
How to Make Your Web Content Print Friendly
WordPress Tutorials
WordPress Developer should learn about apply_filters() and why?
WordPress Tutorials
How to Remove Images from the_content() but Preserve HTML Formating
WordPress Tutorials
Easier Retina Support for Your WordPress Themes