There are couple of advantage if you load your jQuery from any CDN. It is a good approach to always use CDN but sometimes what if the CDN is down. So if you have loaded your jQuery from any CDN and it went down then your jQuery code will stop working, what to do in such situation.
Hang on, there is a solution for this as well. Below given jQuery code checks whether jQuery is loaded from Google CDN or not, if not then it references the jQuery.js file from your folder.
It first loads the jQuery from Google CDN and then check the jQuery object. If jQuery is not loaded successfully then it will references the jQuery.js file from hard drive location.
No comments:
Post a Comment