DOMContentLoaded

Table of contents

  1. 1. Browser compatibility
    1. 1.1. Gecko notes
  2. 2. Specification

The DOMContentLoaded event is fired at the page's Document object when parsing of the document is finished. By the time this event fires, the page's DOM is ready, but the referenced stylesheets, images, and subframes may not be done loading; use the "load" event to detect a fully-loaded page.

  • Interface :Event
  • Synchronicity :yes
  • Bubbles : yes
  • Target : Document
  • Cancelable : no (but see the "Browser compatibility" section below)
  • Default action : none

Note: Stylesheet loads block script execution, so if you have a <script> after a <link rel="stylesheet" ...>, the page will not finish parsing - and DOMContentLoaded will not fire - until the stylesheet is loaded.

The event bubbles to window . It is not fired on the parent page for document loads in subframes.

Browser compatibility

  • Desktop
  • Mobile

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 0.2 1.0 (1.7 or earlier) 9.0 9.0 3.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1) ? (Yes) (Yes)

Gecko notes

In Gecko (as of 1.9.2) this event reports itself as cancelable, but since it doesn't have a default action, canceling it has no effect.

Bubbling for this event is supported by at least Gecko 1.9.2, Chrome 6, and Safari 4.

DOMContentLoaded has been supported by Mozilla since before version 1.0, and was since implemented by other browsers (including IE 9) and has now been standardized in the HTML5 specification.

Tags (4)

Edit tags

Attachments (0)

 

Attach file