有没有办法与执行分开下载时间脚本?
我想为我的主要JavaScript负载启动一些定时变量。我可以做类似的事情:
<script>
performance.mark('script-start')
</script>
<script src="something.js"></script>
然后在某个地方添加performance.Measure('script-start')
。
问题在于,这将使脚本下载时间和脚本解析以及(一部分)执行时间计时。有没有办法分别下载和执行脚本?
I'd like to instrument some timing variables for my main JavaScript load. I could do something like this:
<script>
performance.mark('script-start')
</script>
<script src="something.js"></script>
Then somewhere in something.js add a performance.measure('script-start')
.
The problem is that this would time both the script download time and the script parsing and (part of) the execution time. Is there a way to time script download and execution separately?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
performance.measure('script-start')
放在something.js
的一开始。这将包括解析时间,但不包括执行时间。除非脚本很大,否则解析时间应该几乎可以忽略不计。您可以通过在第一个
&lt; script&gt;
标签中将下载和执行时间分别为下载和执行。然后放在something.js
的开头。Put
performance.measure('script-start')
at the very beginning ofsomething.js
. This will include the parse time, but not the execution time. Unless the script is enormous, the parse time should be almost negligible.You could time the download and execution separately by putting
performance.mark('download-start')
in the first<script>
tag. Then putat the beginning of
something.js
.