W3cubDocs

/Web APIs

PerformanceNavigationTiming: activationStart property

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

The activationStart read-only property represents the time between when a document starts prerendering and when it is activated.

Value

A DOMHighResTimeStamp representing the duration between document prerendering start and activation in milliseconds.

The value is 0 if the page has not prerendered or is still prerendering.

Examples

Detecting prerendered pages

When a prerendered document is activated, activationStart is set to the current time. The following function can check whether a page is prerendering or has already prerendered:

js

function pagePrerendered() {
  return (
    document.prerendering ||
    self.performance?.getEntriesByType?.("navigation")[0]?.activationStart > 0
  );
}

Measuring user-perceived performance milestones

With prerendered pages, a page may have been created long before it was actually navigated to. When using the Performance API on prerendered pages, it is vital to compare returned values with activationStart in order to avoid misleading measurements.

js

// Time to when activation occurred
let activationStart =
  performance.getEntriesByType("navigation")[0].activationStart;

// Time to first paint
let firstPaint = performance.getEntriesByName("first-paint")[0].startTime;

// Time to first contentful paint
let firstContentfulPaint = performance.getEntriesByName(
  "first-contentful-paint",
)[0].startTime;

console.log("time to first paint: " + (firstPaint - activationStart));
console.log(
  "time to first-contentful-paint: " + (firstContentfulPaint - activationStart),
);

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
activationStart 108 108 No No 94 No 57 57 No 43 No 7.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming/activationStart