1
目前,我有以下幾點:有沒有辦法結合加載jQuery和Google Analytics?
<script src="http://www.google.com/jsapi?key=..." type="text/javascript"></script>
<script>
//<![CDATA[
google.load('jquery', '1.6');
//]]>
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '...']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
好像兩個非常不同的方式來加載JS。有什麼方法可以將這些結合起來使負載效率最高?
感謝。一個問題。我認爲async = true是新的。它適用於所有browswers或只是一些? – Michael
https://developer.mozilla.org/En/HTML/Element/Script#Attributes – Acorn
@Michael它支持在新的瀏覽器..檢查了這一點http://stackoverflow.com/questions/1834077/which-browsers-support -script - 異步異步 –