How to replace wordpress default jQuery with Google Library jQuery

Mahabubur Rahman
0

Wordpress load jQuery library from the wordpress project stored script. So if we want to load jQuery form Google Library then we need to create a simple function which load jQuery from google library and also stop lode jquery from wordpress default location. That means we want to replace the loading way of jQuery way form wordpress default to Google library. The function is following -

//Create function to load jQuery from Google Library
function replace_jquery() {
if (!is_admin()) {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', false, '1.11.1');
wp_enqueue_script('jquery');
}
}
add_action('init', 'replace_jquery');

Post a Comment

0Comments
Post a Comment (0)