Measuring performance and understanding user navigation is supported by most of the browsers now natively through their implementations of “Navigation & Timing” W3C spec. It doesn’t need any additional library.
For example: The below code snippets work correctly on both IE(tested on version is 11.x) and Chrome (tested on 40.x).
Measure page load time.
var perfData = window.performance.timing; |
var pageLoadTime = perfData.loadEventEnd – perfData.navigationStart; |
Measure request response time.
var connectTime = perfData.responseEnd – perfData.requestStart; |
Several other metrics can be captured directly using the window.performance object ex: window.performance.memory returns information about memory consumption of the page, window.performance.navigation.type tells if a page load is triggered by a redirect, back/forward button or normal URL load.
Measure Ajax Requests
|
---|
Measure Custom events
Very similar to measuring Ajax Requests using mark and measure.
More information Here:
- http://www.w3.org/TR/navigation-timing/
- https://developer.mozilla.org/en-US/docs/Navigation_timing
- http://www.html5rocks.com/en/tutorials/webperformance/basics/
- http://stackoverflow.com/questions/2530228/jquery-or-javascript-to-find-memory-usage-of-page
- http://www.w3.org/TR/user-timing/
- http://stackoverflow.com/questions/14657849/can-i-use-the-browser-navigation-timing-api-for-ajax-events-in-single-page-apps