Skip to content Skip to sidebar Skip to footer

Should I Use Google's Jsapi In Production Code?

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?

Solution 1:

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.

Solution 2:

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.

Solution 3:

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.

Solution 4:

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().

Solution 5:

I believe that the Google JSAPI is also asynchronous and helps avoid the "toll booth" best described by "Imagine there's a 4-lane highway between your web browser and the internet itself. This highway is optimize to let pictures, text, and css fly by. But, when it comes to external scripts, the highway creates a toll booth that slows traffic. The worst part is that pictures text, and css caught behind these scripts have to wait until they pass through" - Andres Vidal

The toll-booth is critical and must be avoided at all times.

Post a Comment for "Should I Use Google's Jsapi In Production Code?"