<script type="text/javascript">//<![CDATA[
// jQuery has already been loaded but this could be equivalent to 
// a function in <body onLoad="">
  var iNavStart=performance.timing.navigationStart;
  var iNavEnd=performance.timing.loadEventEnd;
  var iPageLoad=iNavEnd-iNavStart;

When the page loads, the console reveals:

iNavStart: 1449594976150
iNavEnd:   0
iPageLoad: -1449594976150

I was expecting this calculation to give me a nice number of milliseconds. Surely iNavEnd shouldn't be 0?

Tested in Chrome 47 and Firefox 42 (both support performance.timing).

Any ideas where I'm going wrong?

1 Answer 1


I believe that Ionut Popa answers this on Stackoverflow in Measuring Site Load Times via performance api:

You need to measure the loadEventEnd after the onload event has finished or else it will be reported as 0, as never happened. (jquery example for attaching to the onload event)

 window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {};
 var timing = performance.timing || {};
 var parseTime = timing.loadEventEnd - timing.responseEnd;
 console.log('Parsetime: ', parseTime);
 }, 0);
  • Thanks Stephen, its the setTimeout part I was missing that makes all the difference! Commented Dec 9, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.