gpt4 book ai didi

javascript - Google Analytics - 是否缓存了 ga.js?

转载 作者:数据小太阳 更新时间:2023-10-29 04:15:12 24 4
gpt4 key购买 nike

这是谷歌推荐你用来调用 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);
})();

当文件被插入到 dom 中时,这是否会阻止 js 文件被浏览器缓存?

最佳答案

没有。缓存基于 ga.js 文件的响应 header 。它是动态插入的,因此它是异步加载的,这意味着加载不会阻止浏览器执行其他事件(渲染、绘画等)。一些浏览器理解脚本标签中的异步属性。注意

ga.async = true;

关于javascript - Google Analytics - 是否缓存了 ga.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5183885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com