I am using this code by Peter Wilson to move jQuery
to footer:
function pwcc_jquery_to_footer( &$wp_scripts ) {
if ( is_admin() ) {
return;
} /*
Move jQuery to the HTML footer
This should be fine but may cause problems with some plugins as it potentially breaks backward compatibility. Well coded plugins should be good.
doing_it_wrong_and_loving_it
*/
$wp_scripts->add_data( 'jquery', 'group', 1 );
$wp_scripts->add_data( 'jquery-core', 'group', 1 );
$wp_scripts->add_data( 'jquery-migrate', 'group', 1 );
}
add_action( 'wp_default_scripts', 'pwcc_jquery_to_footer' );
It works in my Wordpress 4.5.2.
There is, however, one complication. It loads below Akismet's js file.
I need it to be above Akismet's js file, as it better optimizes minification by the plugin W3 Total Cache.
Any way to move it on top of the footer?