Skip to main content

Confirm

Are you sure?

Glossary

DOMContentLoaded

The first moment the document is complete — which is not the moment the page is.

By · Last updated: September 2026

TL;DR

DOMContentLoaded is the browser event that fires once the HTML document has been fully parsed and its deferred scripts have run, without waiting for images, stylesheets that block nothing, or iframes. It comes before the load event, and on a client-rendered page it fires long before the content exists.

Free plan, no credit card. 1,000 credits a month.

How it works

Where it sits in a page load

  1. 1
    The browser receives the HTML and starts parsing. Classic <script> tags pause the parser while they download and run.
  2. 2
    Parsing ends. Scripts marked defer run, in order.
  3. 3
    DOMContentLoaded fires on document. The DOM tree is complete.
  4. 4
    Images, iframes and other subresources finish. load fires on window.
  5. 5
    The page's own JavaScript carries on: API calls, lazy content, analytics. Tools that wait for the network to go quiet wait for this.

async scripts are not waited for — they run whenever they arrive, before or after the event. Code that needs the DOM listens for it:

Run once the DOM exists
document.addEventListener("DOMContentLoaded", () => {
  document.querySelector("#year").textContent = new Date().getFullYear();
});

In practice

What it means when you fetch pages

For a server-rendered page, the DOM at DOMContentLoaded already holds the text, so reading it there is fast and complete. For a client-rendered page it holds the empty shell, because the scripts that build the content have only just started. Automation tools offer it as a wait option (waitUntil: "domcontentloaded") for speed; it is the wrong default for reading content.

It matters for errors too. A script that throws during parsing throws before DOMContentLoaded; a failed API call throws seconds after load. Capture only up to the event and you miss most of what goes wrong.

URLpipe

URLpipe

URLpipe reads pages after load and after the network settles (see networkidle), not at DOMContentLoaded. /console listens from the start of the load until then, and then a little longer, so errors raised by late scripts are in the result.

FAQ

Frequently asked questions

What is the difference between DOMContentLoaded and load?
DOMContentLoaded fires when the HTML is parsed and deferred scripts have run. load fires later, once images, iframes and other subresources have finished too.
Does DOMContentLoaded wait for CSS?
Not directly, but a script that comes after a stylesheet waits for that stylesheet before it runs, and the event waits for the script — so in practice CSS can delay it.
Is DOMContentLoaded the same as jQuery's ready?
Effectively yes: $(document).ready runs its callback at DOMContentLoaded, or immediately if the event has already fired.

See it on your own pages.

Free plan, no card. Confirm your email and your API key is live — you'll be making real requests in minutes.