DOM - Ready event (Readiness|readyState)

About

A page in a ready state, all images are not finished downloading, including banner ads.

State

The readyNess can be read in the readyState property of the document

document.readyState
complete

The document.readyState property returns:

  • loading while the Document is loading, (ie if the document is associated with an HTML parser, an XML parser, or an XSLT processor)
  • interactive once it is finished parsing but still loading sub-resources,
  • and complete once it has loaded.

The readystatechange event fires on the Document object when this value changes.

Timeline Event Reference

Run code at event

Native Javascript

Same as Browser - DOMContentLoaded event (page load) ?

window.addEventListener('DOMContentLoaded', function () {
  console.log("It's ready!")
})

Jquery

To run code as soon as the document is ready to be manipulated in Javascript - JQuery with the Ready event

$( document ).ready(function() {
 
    // Your code here.
 
});

Powered by ComboStrap