我與谷歌JavaScript客戶端API玩,我想知道的代碼以下兩個部件之間的區別是什麼的正確方法:什麼是加載谷歌JavaScript客戶端庫和自定義端點客戶端庫
//in the html file
<script src="https://apis.google.com/js/client.js?onload=gapiInit"></script>
//in a javscript file
gapiInit = function() {
alert("Loading the Libs!");
var numApisToLoad;
var callback = function(){
if(--numApisToLoad == 0) {
alert('APIs Ready!');
}
};
numApisToLoad = 1;
gapi.client.load('plus','v1',callback);
};
這..
<script>
// Asynchronously load the client library
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
我已經從不同的例子,谷歌提供的谷歌加號例如,在使用後者,而云終端的例子使用前見過..
他們只是兩種做同樣的事情嗎?我真的很重要嗎?從developer.google.com
//端點
例子 -
https://developers.google.com/appengine/docs/java/endpoints/consume_js
//加上登錄(似乎兩者都做) -
https://developers.google.com/+/web/people/
//只async script .. -
developers.google.com/+/web/api/javascript
(對於狡猾的鏈接對不起,堆棧溢出不會讓我把超過兩個)
任何洞察力將不勝感激。
謝謝大家。
三江源的洞察力,所以看起來它們導致在客戶端和加模塊被加載相同的「國家」 ......? –
或者只是在腳本標籤中使用'async defer' ...不需要恐慌 – vsync