Placing the jQuery script in the footer enhances the website’s performance.
add_action( 'wp_enqueue_scripts', function() {
if ( is_admin() ) {
return;
}
$scripts = wp_scripts();
if ( isset( $scripts->registered['jquery'] ) ) {
$scripts->add_data( 'jquery', 'group', 1 );
}
if ( isset( $scripts->registered['jquery-core'] ) ) {
$scripts->add_data( 'jquery-core', 'group', 1 );
}
if ( isset( $scripts->registered['jquery-migrate'] ) ) {
$scripts->add_data( 'jquery-migrate', 'group', 1 );
}
});