JavaScript Document prerendering Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

Document.prerendering is a read-only boolean that is true while the document is prerendering via the Speculation Rules API (MDN).

Read the notes below before you get or set this property. Prefer feature detection when support is limited.

Syntax

Use document.prerendering. Start with this line.

JavaScript
document.prerendering
CallWhat it does
document.prerenderingPrimary signature.

Built into the browser. Read or assign document.prerendering — no import required.

Library declarations
JavaScript
document.prerendering

Parameters

ParameterDescription
GetterRequired. true while prerendering
SetterOptional. Read-only

Return Value

Return ValueDescription
*The current value of document.prerendering.

JavaScript Examples

Example 1 — Read document.prerendering

MDN-style status check while a page may be prerendering.

JavaScript
if (document.prerendering) {
  console.log("got this far during prerendering!");
} else {
  console.log("not prerendering");
}
Try It Yourself

How It Works

  1. Read the boolean. true only during active prerender.
  2. Normal visits. Tutorial/editor loads usually print the else branch.
  3. Do not assign. The property is read-only.
  4. Feature-detect in real apps. The API is Experimental.

Example 2 — Defer Work Until Activation

MDN pattern: wait for prerenderingchange when prerendering is active.

JavaScript
function initAnalytics() {
  console.log("analytics start");
}

if (document.prerendering) {
  document.addEventListener("prerenderingchange", initAnalytics, {
    once: true,
  });
} else {
  initAnalytics();
}
Try It Yourself

How It Works

  1. Branch on status. If prerendering, delay init.
  2. Listen once. prerenderingchange runs when the user activates the page.
  3. Else run now. Normal loads should not wait forever.
  4. Safer side effects. Avoid counting “views” that the user never saw.

Example 3 — Three-Way Activation Check

MDN’s combined check for current, past, or no prerender.

JavaScript
if (document.prerendering) {
  document.addEventListener(
    "prerenderingchange",
    () => {
      console.log("Prerender activated after this script ran");
    },

    { once: true }
  );
} else if (
  performance.getEntriesByType("navigation")[0]?.activationStart > 0
) {
  console.log("Prerender activated before this script ran");
} else {
  console.log("This page load was not via prerendering");
}
Try It Yourself

How It Works

  1. Current prerender. Wait for prerenderingchange.
  2. Past prerender. activationStart > 0 means activation already happened.
  3. Normal load. Neither signal is set.
  4. Use all three. MDN: this combination measures activations reliably.

Browser Support

Document.prerendering is Experimental with Limited availability on MDN (not Baseline). Feature-detect and keep a normal-load code path.

✓ Experimental · Limited availability

Document.prerendering

Read-only boolean for Speculation Rules prerender — support is growing.

Limited Feature-detect first
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
prerendering Limited

Bottom line: Safe to teach with detection. Pair with prerenderingchange and activationStart when measuring or delaying work.

Frequently Asked Questions

A boolean. MDN: true if the document is currently prerendering via the Speculation Rules API; false if it is not, including after prerender finishes or when the page was never prerendered.
MDN marks Document.prerendering as Experimental and Limited availability (not Baseline). It is not Deprecated or Non-standard.
When the page is not prerendering, when prerender has finished and the page was activated, or when the page loaded normally without prerender (MDN).
MDN: combine document.prerendering, the prerenderingchange event, and performance.getEntriesByType("navigation")[0]?.activationStart > 0.
Usually no. MDN recommends delaying side effects until activation — use prerenderingchange when prerendering is true, otherwise run immediately.
hidden / visibilityState describe page visibility. prerendering means the document is loading in the background via Speculation Rules before the user navigates to it.

Next: readyState

Learn the document’s loading state string.

readyState tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful