Last Updated: February 25, 2016
·
7.864K
· Kresimir Pendic

Wordpress load jquery in the footer!

By default Wordpress will load jquery lib in the header if you include it in function.php like this:

wp_enqueue_script( 'jquery' );

But if you'd like to be loaded in the footer so that maybe your page would load much faster with css and html only.. you can use this snippet:

<?php
function addthemejs() { 
    wp_deregister_script( 'jquery' ); // remove standard jquery
    wp_enqueue_script( 'jquery', get_template_directory_uri() .'/js/jquery.js' ,,, true );
}

//----------------------------------------------------------/
//  call the enqueue hook
//----------------------------------------------------------/

add_action('wp_enqueue_scripts', 'addthemejs');

cheers, k

1 Response
Add your response

You need to be careful with doing this, as some plugins load jQuery dependent scripts into the header of your site which can cause problems.

However, if this isn't an issue you should definitely place jQuery into the footer

over 1 year ago ·