Order of execution of jquery document ready

Your handlers are being pushed into an array (readyList) for executing in order later, when the document is ready.

They’re queued like this:

readyList.push( fn );

And executed when ready like this:

var fn, i = 0;
while ( (fn = readyList[ i++ ]) ) {
  fn.call( document, jQuery );
}

If the document is already ready, then they’ll execute immediately, which is still in order.

Leave a Comment