5

With which will function(){} fire first?

A) window.addEvent('domready', function(){});
B) window.addEvent('load', function(){});
JamesBrownIsDead
  • 81
  • 1
  • 1
  • 4

2 Answers2

12

domready will fire first.

http://demos111.mootools.net/DomReadyVS.Load

Björn
  • 27,479
  • 9
  • 63
  • 81
  • 1
    sometimes it fires too soon in IE with 1.11, i have been forced to use load instead. – Dimitar Christoff Nov 05 '09 at 12:04
  • 1
    @JamesBrownIsDead -- the concept of the domready event is that the structure of the html and the resulting DOM (document object model) will have loaded. So, the "skeleton" of the page has loaded. While load is the event that fires once all that is done AS WELL AS all the images and whatever other ancillary content files. – artlung Nov 09 '09 at 04:18
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Mistalis Mar 07 '17 at 09:54
2

domready comes first as load waits till everything on the page is loaded before executing.