Daily Archives: 2014/07/04

將載入Google Plus One的JavaScript改寫成非同步載入寫法

原有的 Google Plus One (G+) 的同步載入 JavaScript 寫法假設是: <script type=”text/javascript” src=”https://apis.google.com/js/plusone.js”> {lang: ‘zh-TW’} </script> 改寫成非同步載入寫法後變成這樣: <script type=”text/javascript”> window.___gcfg = {lang: ‘zh-TW’}; (function() { var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true; po.src = ‘https://apis.google.com/js/plusone.js’; var s = document.getElementsByTagName(‘script’)[0]; … Continue reading

Posted in JavaScript, 實作 | Tagged , , | Leave a comment