A document is in a ready state when the DOM has been built.
Any work that tries to interact with the DOM should wait for the DOM to be ready.
For an HTML page, in a browser, all images are not finished downloading, including banner ads.
The readyNess can be read in the readyState property of the document
document.readyState
complete
The document.readyState property returns:
The readystatechange event fires on the Document object when this value changes.
In Native Javascript, dom ready is known as DomContentLoaded.
window.addEventListener('DOMContentLoaded', function () {
console.log("It's ready!")
})
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.
console.log("Ready !")
});