Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a native Javascript implementation of jQuery's document.ready()?

 $(document).onload()

it's internally implemented by window.onload event

then what about

 $(document).ready()

what's the native javascript to implement it?

like image 415
omg Avatar asked Aug 16 '09 04:08

omg


People also ask

What is JavaScript equivalent of document ready?

jQuery $(document). ready() Equivalent in JavaScript This event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.

Why do we start our code with document ready () in jQuery?

ready() function will load as soon as the DOM is loaded and before the page contents are loaded. You should wrap all your javascript code with this function to ensure that the code only runs when the page is fully rendered.

Is window onload same as document ready?

The document. ready event occurs when the HTML document has been loaded, and the window. onload event occurs always later, when all content (images, etc) has been loaded. You can use the document.


1 Answers

For Mozilla, Opera and webkit, jQuery binds the DOMContentLoaded event, for IE jQuery uses the onreadystatechange event.

Look the internal bindReady function on the jQuery source code.

like image 130
Christian C. Salvadó Avatar answered Nov 15 '22 21:11

Christian C. Salvadó