jquery.min.js (Google CDN) & jquery-migrate.min.js in footer
-
Is this code correct? Can it be improved further? jquery-migrate.min.js isn’t in Google CDN?
I also read that it’s possible to automatically check which version WordPress is currently using and download that version from Google CDN.
Below code seems to work, but of course it will have to be updated manually when WordPress uses different versions.
function my_init()
{
if (!is_admin())
{
wp_deregister_script(‘jquery-core’);wp_register_script(‘jquery-core’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js’, FALSE, ‘1.11.0’, TRUE);
wp_enqueue_script(‘jquery-core’);
wp_deregister_script(‘jquery-migrate’);
wp_register_script(‘jquery-migrate’, ‘/wp-includes/js/jquery/jquery-migrate.min.js’, FALSE, ‘1.2.1’, TRUE);
wp_enqueue_script(‘jquery-migrate’);
}
}
add_action(‘init’, ‘my_init’);
- The topic ‘jquery.min.js (Google CDN) & jquery-migrate.min.js in footer’ is closed to new replies.