Calculate page load time of page

123 views Asked by At

I am trying to create a script to calculate total page load time of page, i am using puppeteer and in some scripts i am using lighthouse, i am confused regarding what to follow like should i follow lighthouse method (web.vitals) or should i follow DOM one, and what will be the correct and accurate way to calculate page load time, kindly do suggest

below is the link to the scripts i made for reference

https://drive.google.com/drive/folders/104gu0J10tL3Sr3QvaeV8n9uzeRyWQLPS?usp=sharing

i am expecting to create a script to calculate page load time accurately like datadog, site24x7, new relic or dynatrace

1

There are 1 answers

4
Monke On BEST ANSWER

This uses DOM which might be more efficient than some other library due to a direct timing frame compared to a library loaded into the website to check when the site is loaded.

let page_load_time = window.performance.timing.domComplete - window.performance.timing.requestStart;
console.log(page_load_time + "(ms)");