Possible duplicate of:
should-i-link-to-google-apis-cloud-for-js-libraries
also many other discussions, including:
Where do you include the jQuery library from? Google JSAPI? CDN? Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail
I was looking at the Tiny MCE plugin example and saw this code in the head
of the document:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.3");
</script>
I've never seen this way to load jQuery.
Yes, definitely. Google encourages it. Everyone benefits. It's more likely to be in their cache, and it's one less file that you have to serve.
As others have pointed out answering similar questions, there's a downside. In some countries (such as Iran), these are apparently blocked, breaking the website.
The benefit is it's hosted on googles super low latency and fast servers. you can also just use
<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script>
its the same effect.
keep in mind that google jsapi loads the scripts only after the document itself is loaded.
So, if (for example) you are using jquery's $(document).ready()
in your web app, you'll have to switch to google.setOnLoadCallback()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With