简体   繁体   中英

Do I need to load the jsapi when loading from google library?

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM