Navigation timing is part of the Performance API that lets you benchmark web applications. It allows to measure various points of page load, including the time it takes for the server to respond. In the attached example we are capturing total page load time, DOM start, DOM interactive, content loaded, DOM complete, and total page render time. These are just a few examples form the API. For the full explanation visit https://www.w3.org/TR/navigation-timing/
#javascript#performance
(function(){timings=window.performance.timing;// Get the time passed between two events in secondsfunctionperformance(start,end){return(end-start)/1000+"s";}// New object to store calculated and human-readable resultslatency={}// CALCULATE THE RESULTS HERE:// Total Page Load Timelatency.totalPageLoadTime=performance(timings.navigationStart,timings.loadEventEnd);// DOM Startlatency.domStart=performance(timings.navigationStart,timings.responseEnd);// DOM Interactivelatency.domInteractive=performance(timings.navigationStart,timings.domInteractive);// DOM Content Loadedlatency.domContentLoaded=performance(timings.navigationStart,timings.domContentLoadedEventEnd);// DOM Completelatency.domComplete=performance(timings.navigationStart,timings.domComplete);// Page Render Timelatency.pageRenderTime=performance(timings.domLoading,timings.domComplete);// Draw results table in the consoleconsole.table(latency);})();