Як завантажувати jQuery з Google CDN

Як завантажувати jQuery з Google CDN


CDN пришвидшує завантаження сайту, але якщо ви ще не використовуєте це на сайті, то можете з jQuery 🙂

Додайте цей код у functions.php:
[php]
// Making jQuery to load from Google Library CDN
function replace_jquery() {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’, ‘//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js’, false, ‘1.12.4’);
//wp_enqueue_script(‘jquery’);
}
// Use only in front-end
if (!is_admin()) {
add_action(‘wp_enqueue_scripts’, ‘replace_jquery’);
}
/**/
[/php]