ped*_*000 8 javascript caching google-analytics
这是谷歌建议你用来调用ga.js文件的代码:
(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);
})();
Run Code Online (Sandbox Code Playgroud)
当文件插入到dom中时这会阻止js文件被浏览器缓存吗?
否.缓存基于ga.js文件的响应标头.它是动态插入的,因此它是异步加载的,这意味着加载不会阻止浏览器执行其他活动(渲染,绘制等).一些浏览器了解脚本标记中的async属性.请注意
ga.async = true;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2651 次 |
| 最近记录: |