简体   繁体   English

脚本加载时间网站加载时间

[英]Script to time Loading Time of Website

I've been trying to optimize the time my site takes to load and want to make measurements to see if things are improving. 我一直在尝试优化网站加载所需的时间,并希望进行测量以查看情况是否有所改善。

Instead of manually reloading the page and logging out the time between when the page begins to load and when it's ready I want to automate it somehow. 我不想手动重新加载页面并注销页面开始加载到准备就绪之间的时间,我想以某种方式使其自动化。

I've been using the command: 我一直在使用命令:

window.performance.timing.domContentLoadedEventEnd- window.performance.timing.navigationStart

I'm quite unexperienced with writing these kinds of scripts, but is there a way to use the above command and location.reload() to do this sort of thing? 我对编写这类脚本没有任何经验,但是有没有一种方法可以使用上面的命令和location.reload()来完成这种事情?

As per the example provided here: https://developer.mozilla.org/en/docs/Web/API/Navigation_timing_API 按照此处提供的示例: https : //developer.mozilla.org/en/docs/Web/API/Navigation_timing_API

var perfData = window.performance.timing; 
var pageLoadTime = perfData.loadEventEnd - perfData.navigationStart;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM