PerformanceNavigationTiming: notRestoredReasons property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The notRestoredReasons read-only property of the PerformanceNavigationTiming interface returns a NotRestoredReasons object providing report data on reasons why the current document was blocked from using the back/forward cache (bfcache) on navigation.

Value

When the associated PerformanceNavigationTiming object represents a history navigation, notRestoredReasons returns a NotRestoredReasons object.

When the PerformanceNavigationTiming object does not represent a history navigation, notRestoredReasons will return null. This is useful for determining whether bfcache is not relevant to a particular navigation (as opposed to notRestoredReasons not being supported, in which case it would return undefined).

Note: notRestoredReasons may return null despite the navigation type being reported as a back/forward navigation. These circumstances include duplicating a back/forward navigation in a new tab and restoring a back/forward navigation tab after a browser restart. In such cases, some browsers copy the navigation type from the original tab, but as these are not actually back/forward navigations, notRestoredReasons returns null.

Examples

PerformanceNavigationTiming data can be obtained from the performance timeline using Performance.getEntriesByType() or PerformanceObserver.

For example, you could invoke the following function to return all PerformanceNavigationTiming objects currently present in the performance timeline and log their notRestoredReasons:

js
function returnNRR() {
  const navEntries = performance.getEntriesByType("navigation");
  for (let i = 0; i < navEntries.length; i++) {
    console.log(`Navigation entry ${i}`);
    let navEntry = navEntries[i];
    console.log(navEntry.notRestoredReasons);
  }
}

The PerformanceNavigationTiming.notRestoredReasons property returns an object with the following structure, which provides reasons why the current document was blocked from using the bfcache. In this example the top-level frame has no embedded child <iframe>s:

json
{
  "children": [],
  "id": null,
  "name": null,
  "reasons": [{ "reason": "unload-listener" }],
  "src": "",
  "url": "example.com"
}

Specifications

Specification
Navigation Timing Level 2
# dom-performancenavigationtiming-notrestoredreasons

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
notRestoredReasons
Experimental
Chrome – Full support
Chrome 125 (Release date: 2024-05-14)
footnote Full support
Edge – Full support
Edge 125 (Release date: 2024-05-17)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 111 (Release date: 2024-06-12)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 125 (Release date: 2024-05-14)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 27 (Release date: 2024-11-06)
footnote Full support
WebView Android – Full support
WebView Android 125 (Release date: 2024-05-14)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

See also