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 Topics:

WordPress Tutorials
Building Your Website with WordPress? Learn How to Optimize it
WordPress Tutorials
How to Detect Mobile or Tablet Condition in WordPress
WordPress Tutorials
Designing and Protecting Your WordPress Site is Easier Than You Think
WordPress Tutorials
The Ultimate SEO Tips For Your WordPress Blog