WordPress is awesome, we know this all. A great thing about WordPress is that it comes locked and loaded with all kinds of JavaScript libraries, including jQuery. It also gives you the power to change the source of those libraries according to your needs. So as default WordPress loads jQuery from your server. You know that it’s always better to load jQuery from google CDN. Let’s say we want to relieve our server of some stress by switching WordPress’ version of jQuery for a hosted solution (or CDN version). We can very easily change the source of jQuery with this function: Three things are going on here. First, we’re using wp_deregister_script() to tell WordPress to forget about the version of jQuery currently being used. We then use wp_register_script() to re-register jQuery (as the script name), using jQuery’s own CDN version. Finally, we use wp_enqueue_script() to add jQuery to our theme or plugin. One thing to note here is that we’re using add_action() , not add_filter() , to add our scripts. Because we’re not making any changes to the content, but instead relying on WordPress to do something in order for our scripts to load, we use an action hook, not a filter hook.
But Jewel, Why you use //ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js instead of http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js , Would you please explain?
Ok Don’t worry, It’s a bless. if you use //ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js the your browser will first search for a cache version of jQuery from the browser as most of the sites use jQuery so your browser will not download jQuery again and again. So your website’s page speed will be fast! You got it? Please let me know which cdn you use? Do you use default source of jQuery or use any CDN?