简体   繁体   中英

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?

As per the example provided here: https://developer.mozilla.org/en/docs/Web/API/Navigation_timing_API

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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