JavaScript Document readyState Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

document.readyState describes the loading state of the document (MDN). When it changes, a readystatechange event fires on document.

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

Syntax

Use document.readyState. Start with this line.

JavaScript
document.readyState
CallWhat it does
document.readyStatePrimary signature.

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

Library declarations
JavaScript
document.readyState

Parameters

ParameterDescription
Writable?Optional. Read-only
Related eventOptional. readystatechange when the value changes

Return Value

Return ValueDescription
*"loading" | "interactive" | "complete"

JavaScript Examples

Example 1 — Read Current readyState

A script at the end of <body> often sees "interactive" or "complete".

JavaScript
console.log(document.readyState);
// "loading" | "interactive" | "complete"
Try It Yourself

How It Works

  1. Read the property — MDN returns one of three strings.
  2. Timing matters — early scripts may see "loading".
  3. Late body scripts often see "interactive".
  4. After full load, you see "complete".

Example 2 — Branch with switch (MDN)

MDN pattern: handle each readiness state differently.

JavaScript
switch (document.readyState) {
  case "loading":
    console.log("Still loading");
    break;
  case "interactive":
    console.log("DOM ready");
    break;
  case "complete":
    console.log("Fully loaded");
    break;
}
Try It Yourself

How It Works

  1. Switch on the string returned by readyState.
  2. loading — parser still working (MDN).
  3. interactive — DOM accessible; sub-resources may continue (MDN).
  4. complete — page fully loaded (MDN).

Example 3 — readystatechange Listener (MDN)

MDN: use readystatechange as an alternative to DOMContentLoaded / load.

JavaScript
document.addEventListener("readystatechange", () => {
  if (document.readyState === "interactive") {
    console.log("like DOMContentLoaded");
  }
  if (document.readyState === "complete") {
    console.log("like load");
  }
});
Try It Yourself

How It Works

  1. Listen on document for readystatechange (MDN).
  2. Check interactive — similar timing to DOMContentLoaded (MDN).
  3. Check complete — similar timing to the load event (MDN).
  4. Attach early — a late listener may miss earlier states.

Browser Support

Document.readyState is a core HTML Document property. MDN marks it Baseline Widely available (since July 2015).

✓ Baseline · Widely available

Document.readyState

loading | interactive | complete. Safe for everyday page-load timing.

99% Widely available
Google Chrome Yes
Yes
Microsoft Edge Yes
Yes
Mozilla Firefox Yes
Yes
Apple Safari Yes
Yes
Opera Yes
Yes
Internet Explorer Yes (legacy)
Yes
readyState Excellent

Bottom line: Use freely in modern browsers. See the MDN readyState reference.

Frequently Asked Questions

MDN: a string describing document loading — loading, interactive, or complete.
No. MDN marks Document.readyState as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
MDN: when the value of readyState changes. Listen on document to react as the page moves through loading → interactive → complete.
MDN: interactive means the document is parsed (DOMContentLoaded is about to fire) while sub-resources may still load. complete means the document and all sub-resources finished (load is about to fire).
Yes. MDN shows checking readyState === "interactive" in a readystatechange handler as an alternative to DOMContentLoaded.
No. It is read-only. You observe the browser’s loading progress; you do not set it.

Next: referrer

Continue with the Document referrer property.

referrer →

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.

14 people found this page helpful