I have included a reference to Google's JQuery library in my markup:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
Is it safe to do this? How do I know Google won't change t开发者_Go百科he address, or remove it altogether? I really can't afford to have my app break without warning.
What do other people do?
Have the best of both worlds. Use theirs for fast, possibly pre-cached, delivery and in case their server goes down (more likely than them moving it) fallback to your own:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
document.write(unescape("%3Cscript src='/path/to/your/jquery' type='text/javascript'%3E%3C/script%3E"));
}
</script>
Taken from: Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail
Yes, it's completely safe. It's also hosted on Google's CDN making it load faster, in most cases, than loading from your own server.
Absolutely, it is what you should do!
http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/
Google offers it for free. Google's servers are fast and above all you save your bandwidth.
It is 100% safe to use Google's hosted jQuery file. In fact, it is actually faster because browsers can download multiple files at once from different servers. Also, if the user has visited a website that uses Google's jQuery before, the script will already be in the cache, causing the page to load faster.
Ad@m
精彩评论