Use onload or ready?

In my application I use

$(document).ready()

What is the difference between this and

$(document).onload()
+5
source share
4 answers

readyit starts when only the DOM is ready, when it onloadstarts with all the resources of the page, including the DOM , images, frames, etc.

Cm:

$ (document) .ready vs. $ (window) .load

Note that readylies with jQuery and not with raw javascript, so I assume that you know that this comparison seems logical too.

+9
source

.ready () is called as soon as the page code is loaded and parsed.

.onload() , //etc.

.ready() jQuery, , ().

+7

.ready()

, DOM.

- jQuery API Docs

.onload()

onload , FRAMESET.

- HTML 4.01

+2

jquery docs.

, Javascript , :

window.onload = function(){ alert("welcome"); }

, . , , Javascript , ( ). window.onload , HTML- , .

, jQuery , , , :

( yahoo), , jquery/js . jquery ready.

+1
source

All Articles