<?php
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' );
function pwcc_action_enqueue_assets() {
/*
Enqueue a file which depends on jQuery
This is the standard technique, the difference been it names jquery-core.
This doesn't load the jQuery-migrate script for backward compatibility. This does require keeping up with jQuery development to ensure you remove calls to deprecated jQuery functions.
*/
wp_enqueue_script(
'pwcc-scripts', // handle
'/path/file.js', // source
array('jquery-core'), // only jQuery, no jQuery-migrate
'20150530-31', // version
true // load in footer
);
}
add_action( 'wp_enqueue_scripts', 'pwcc_action_enqueue_assets' );