1
私は現在、次があります。jQueryとGoogleアナリティクスの読み込みを組み合わせる方法はありますか?
<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をロードするには、2つの非常に異なった方法のように思えます。これらを組み合わせて負荷が最も効率的な方法がいくつかありますか?
感謝を。一つの質問。私はasync = trueが新しいと思う。それはすべてのブラウザーで使用できますか? – Michael
https://developer.mozilla.org/En/HTML/Element/Script#Attributes – Acorn
@Michaelそれは新しいブラウザでサポートされています。これをチェックしてくださいhttp://stackoverflow.com/questions/1834077/which-browsers-support -script-async-async –