The Document readystatechange event fires when document.readyState changes. Typical values: loading, interactive, and complete (MDN). It is not cancelable and does not bubble.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for readystatechange. Start with this line.
JavaScript
addEventListener("readystatechange", fn)
Call
What it does
addEventListener("readystatechange", fn)
Primary signature.
Built into the browser. Listen with document.addEventListener("readystatechange", …) — no import required.
Library declarations
JavaScript
addEventListener("readystatechange", fn)
Parameters
Parameter
Description
Listener on document
Required. Event does not bubble (MDN)
Read readyState
Required. Event itself has no state payload
onreadystatechange
Optional. Handler property (one assignment)
Return Value
Return Value
Description
*
Fires as a Document event (listener receives the Event object).
JavaScript Examples
Example 1 — Log Each readyState
MDN style: print document.readyState whenever the event fires.
Check first. If already complete, run immediately.
Else listen. Wait for the transition to complete.
Filter. Ignore interactive if you only want full resources.
Use case. Measuring layout that depends on images, or post-load cleanup.
Compatibility
Browser Support
Documentreadystatechange is Baseline Widely available (MDN, since July 2015). It is a standard Document event — not Deprecated, Experimental, or Non-standard.
✓ Baseline · Widely available
Document readystatechange
Fires when document.readyState changes. Listen on document — the event does not bubble.
99%Modern browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
readystatechangeExcellent
Bottom line: Safe for virtually all browsers students use today. Pair with document.readyState, and guard late scripts so you do not miss interactive or complete.
Frequently Asked Questions
It fires when the Document readyState attribute has changed. Typical values are loading, interactive, and complete. Read document.readyState inside the handler to see the new state (MDN).
No. MDN marks Document readystatechange as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
No. MDN states the event is not cancelable and does not bubble. Listen on document.
readyState moves loading → interactive → complete. DOMContentLoaded is closely tied to interactive (after deferred/module scripts). The window load event is closely tied to complete (MDN).
Yes. You can use document.onreadystatechange or document.addEventListener("readystatechange", …).
Use DOMContentLoaded when you only care that the DOM is ready. Use readystatechange when you want every readyState transition, or a switch on loading / interactive / complete (MDN).