我不需要jQuery来可立即在页面加载的最佳方式:这是加载谷歌,分析和jQuery
到目前为止,我有以下几点:
<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;
var gb = document.createElement('script'); gb.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
gb.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
s.parentNode.insertBefore(gb, s);
})();
</script>
我不是100%确定这是最有效的方法。请有人告诉我,如果我以最好的方式做事。
谢谢
最有效的方面是什么?什么最好的方法?性能?可用性?您至少会让依赖jQuery的网站在其加载完成之前不能正确显示。 – Niklas
“最佳途径”太主观了。具体来说,你想实现什么? – Scottie
你好。对不起,如果我的问题不是很清楚。我确实提到我不需要jQuery在页面加载时可用。我在寻找的是一个尽可能快的页面。 jQuery在使用时通常需要在页面加载后超过10秒钟。 – UCC