Calculate page load time of page

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

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


  • 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)");