Another advantage of fetching script from the Google’s CDN is that it will release some overload of our server. Using the Google Libraries CDN eliminates one request to our site, allowing more of our local content to downloaded in parallel. This will eventually help in improving the performance of our site.
The only disadvantage is that if the connection to the CDN were to fail, our site would be left with no jQuery library which could be a big deal if we run a jQuery intensive website. If it happens then there should be some mechanism to fetch the library from other source or from our own locally hosted location.
How to implement?
This is fairly easy and short. Only two lines of code will do the job. In first line, script is fetched from the Google’s CDN. Second line will grab the library locally if the CDN is unable to provide the script.