javascript - Track page download time for different pages for analytic purposes -


i trying build analytic system tracks performance of pages of websites.

the website content-driven same template used pages. right use @ page start:

var time  = date.now() 

...and @ end of page use this:

date.now - time 

...and send difference tracking api, stores data.

could please suggest better way, did not find reviews method.

the navigation timing api provides data can used measure performance of website. unlike other javascript-based mechanisms have been used same purpose, api can provide end-to-end latency data can more useful , accurate.

function onload() {    var = new date().gettime();   var page_load_time = - performance.timing.navigationstart;   console.log("user-perceived page loading time: " + page_load_time); } 

there many measured events given in milliseconds can accessed through performancetiming interface:

performance fields description

for details see http://www.w3.org/tr/navigation-timing-2/ or experiment window.performance object.

actually recommend use existing js tools such measurements. example, http://www.devmetrics.io , lib https://github.com/devmetrics/devmetrics-js, provide data ui see results.

function onload() {    devmetrics.measurepageload(); } 

page load time graph


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -