0

I am using the google library API. Up until now I had just included a link to javascript with a script tag. Now I'm reading more carefully and the instructions require me to have a line before that referencing the google.com/jsapi. Does anyone know if this is REALLY required. Things work without it and I prefer not to load yet another script.

Here's the instructions from google web page:

To begin using the Libraries API, include the following script in the header of your web page. Enter your own Google API key where it says INSERT-YOUR-KEY.

Warning: This example won't work unless you use your own API key. In the example below, replace "INSERT-YOUR-KEY" with your own, unique key.

<script type="text/javascript" src="https://www.google.com/jsapi?key=INSERT-YOUR-KEY"></script>

Next, you load the libraries. The preferred method is to load the libraries via standard tags (as in <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>, which will result in the fastest loads.

You can also load any number of libraries via google.load() as follows:

David Thomas
  • 249,100
  • 51
  • 377
  • 410
Michael
  • 11
  • 1

1 Answers1

0

That library is only required if you are using Google JavaScript libraries (for integrating Google products into your website). If you are only using the jquery library, you do NOT need to load the jsapi.

If, however, you want to use the google.load() command to load libraries (even jquery) then you most include the jsapi file first. Since it sounds like you're using straight-up script tags, you do not need to use google.load().

Nathan Bell
  • 2,364
  • 2
  • 18
  • 16
  • Thanks Nathan. How about the advantages of using google.load(). I heard it reduces load time but when I read the google page it specifically said "The preferred method is to load the libraries via standard tags " – Michael Jun 20 '11 at 03:59
  • @Michael I've seen that claim before, as well... but frankly I don't really see how it would improve load time. Whether you use Google's CDN to load jquery or google.load(), the library is coming from the same place in largely the same way. If anything, actually, I would expect the – Nathan Bell Jun 20 '11 at 04:14
  • @Michael and if that doesn't sound very satisfactory, try here :) http://stackoverflow.com/questions/208869/what-are-advantages-of-using-google-loadjquery-vs-direct-inclusion-of-ho – Nathan Bell Jun 20 '11 at 04:15