Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Onload or ready?

In my application i am using

$(document).ready()

What is the difference between this and

$(document).onload()
like image 494
Dean Avatar asked Jul 07 '10 19:07

Dean


1 Answers

The ready is triggered when only the DOM becomes ready while onload triggers when all resources of the page including DOM, images, frames, etc have loaded.

See:

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

Note that ready lies with jQuery not raw javascript so I assume you know that and that way comparison seems logical.

like image 159
Sarfraz Avatar answered Oct 12 '22 05:10

Sarfraz