PerformanceNavigationTiming: activationStart property

Experimental:This is anexperimental technology
Check theBrowser compatibility tablecarefully before using this in production.

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

Value

ADOMHighResTimeStamprepresenting the duration between document prerendering start and activation in milliseconds.

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

Examples

Detecting prerendered pages

When a prerendered document is activated,activationStartis set to the current time. The following function can check whether a page isprerenderingor 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 thePerformance APIon prerendered pages, it is vital to compare returned values withactivationStartin 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

Specification
Prerendering Revamped
#dom-performancenavigationtiming-activationstart

Browser compatibility

BCD tables only load in the browser

See also