好吧,第一个必须提出两个请求,而第二个则提出一个。这真的取决于你想要做什么,谷歌加载器提供了许多有用的选项:
从示例:
function loadMaps() {
google.load("maps", "2", {"callback" : mapsLoaded});
}
你可以指定一个回调,这取决于你想要完成的事情。
此外,请查看自动加载,它可以减少使用 Google API 所需的请求量:
<script src="https://www.google.com/jsapi?autoload=%7B%22modules%22%3A%5B%7B%22name%22%3A%22search%22%2C%22version%22%3A%221.0%22%2C%22language%22%3A%22en%22%7D%2C%7B%22name%22%3A%22maps%22%2C%22version%22%3A%222.X%22%7D%2C%7B%22name%22%3A%22elements%22%2C%22version%22%3A%221.0%22%2C%22packages%22%3A%5B%22localsearch%22%5D%7D%5D%7D"></script>