Measuring performance with the Navigation Timing API
Navigation Timing is a W3C Standard JavaScript API for measuring performance on the Web. The API provides a simple way to get accurate and detailed timing statistics natively for page navigation and load events. It is available on Internet Explorer 9, Google Chrome, Firefox, and WebKit-based browsers.
The API is accessed via the properties of the timing interface of the window.performance
object using JavaScript.
Each performance.timing
attribute shows the time of a navigation event when the page was requested or when the page load event was measured in milliseconds since midnight of January 1, 1970 (UTC). A zero value means that an event did not occur.
The order of the performance.timing
events is shown in the following diagram from the Navigation Timing draft:
Getting ready
Identify a test where you want to measure the performance as well as decide what performance counters you want to measure.
How to do it...
We need to access the window.performance...