Hi I was looking for a way to move wordpress default jQuery to the footer and I saw this answer: https://wordpress.stackexchange.com/a/225936/50584
So, I tried this approach in my child theme's functions.php
file:
add_action( 'wp_enqueue_scripts', function() {
// Move jQuery to the footer
wp_scripts()->add_data( 'jquery', 'group', 1 );
wp_scripts()->add_data( 'jquery-core', 'group', 1 );
wp_scripts()->add_data( 'jquery-migrate', 'group', 1 );
});
But it is not pushing jquery to the footer. Any idea guys why is this happening? I want to avoid the de-register
& re-register
way of doing this.
Any help will be highly appreciated.
Important Update:
Since WP v3.9 there is no way of putting jquery scripts in your footer rather than using the de-register
& re-register
option. It is just simply cannot be done as the author pointed out below.