The Navigation Timing API provides data that can be used to measure the performance of a web site. Unlike JavaScript-based libraries that have historically been used to collect similar information, the Navigation Timing API can be much more accurate and reliable.

This article currently describes Navigation Timing Level 1. There is a specification for Level 2, but it is not yet covered here.

Concepts and usage

You can use the Navigation Timing API to gather performance data on the client side which you can then transmit to a server using XMLHttpRequest or other techniques. Also, the API lets you measure data that was previously difficult to obtain, such as the amount of time needed to unload the previous page, how long domain lookups take, the total time spent executing the window's load handler, and so forth.

Interfaces

Performance
The window.performance property returns a Performance object. While this interface is defined by the High Resolution Time API, the Navigation Timing API adds two properties: timing and navigation, of the types below.
PerformanceNavigationTiming
Provides methods and properties to store and retrieve metrics regarding the browser's document navigation events. For example, this interface can be used to determine how much time it takes to load or unload a document.
PerformanceTiming
Used as the type for the value of timing, objects of this type contain timing information that can provide insight into web page performance.
  PerformanceNavigation
The type used to return the value of navigation, which contains information explaining the context of the load operation described by this Performance instance.

The Navigation Timing API can be used to gather performance data on the client side to be sent to a server via XHR as well as measure data that was very difficult to measure by other means such as time to unload a previous page, domain look up time, window.onload total time, etc.

Examples

Calculate the total page load time

To compute the total amount of time it took to load the page, you can use the following code:

var perfData = window.performance.timing; 
var pageLoadTime = perfData.loadEventEnd - perfData.navigationStart;

This subtracts the time at which navigation began (navigationStart) from the time at which the load event handler returns (loadEventEnd). This gives you the perceived page load time.

Calculate request response time

You can calculate the time elapsed between the beginning of a request and the completion of getting the response using code like this:

var connectTime = perfData.responseEnd - perfData.requestStart;

Here, the time at which the request was initiated (requestStart). from the time at which the response was finished being received (responseEnd).

Calculate page render time

As another example of an interesting piece of data you can obtain using the Navigation Timing API that you can't otherwise easily get, you can get the amount of time it took to render the page:

var renderTime = perfData.domComplete - perfData.domLoading;

This is obtained by starting with the time at which loading of the DOM and its dependencies is complete (domComplete) and subtracting from it the time at which parsing of the DOM began (domLoading).

Specifications

Specification Status Comment
Navigation Timing Level 2 Working Draft Adds PerformanceNavigationTiming
Navigation Timing Recommendation Initial definition.

Browser compatibility

Window.performance.timing

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic support
Deprecated
Chrome Full support 6Edge Full support 12Firefox Full support 7IE Full support 9Opera Full support 15Safari Full support 8WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS Full support 9.2Samsung Internet Android ?
connectEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
connectStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domComplete
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domContentLoadedEventEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari Full support 8WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS Full support 9.2Samsung Internet Android ?
domContentLoadedEventStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domInteractive
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domLoading
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domainLookupEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
domainLookupStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
fetchStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS Full support YesSamsung Internet Android ?
loadEventEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
loadEventStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
navigationStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS Full support YesSamsung Internet Android ?
redirectEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
redirectStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
requestStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
responseEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
responseStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
secureConnectionStart
Deprecated
Chrome Full support 6Edge Full support 18Firefox Full support 56IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile ? Firefox Android Full support 56Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
toJSON
Deprecated
Chrome Full support 44Edge Full support YesFirefox Full support 25IE Full support 9Opera Full support 32Safari Full support YesWebView Android Full support 44Chrome Android Full support 44Edge Mobile Full support YesFirefox Android Full support 25Opera Android Full support 32Safari iOS Full support YesSamsung Internet Android ?
unloadEventEnd
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?
unloadEventStart
Deprecated
Chrome Full support 6Edge Full support YesFirefox Full support 7IE Full support 9Opera Full support 15Safari No support NoWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 7Opera Android Full support 15Safari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.