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
Written by kreso
Related protips
1 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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#