jQuery source code analysis (5) - jQuery's ready () in the end when to perform

var jQuery = function(){};
jQuery.extend({
  isReady: false,
  ready: function(wait){
    if(!document.body) {
       return setTimeout(jQuery.ready);
    }
    jQuery.isReady = true;
 }
});
When document.body not exist, the DOMContentLoaded not completed and, therefore, into the setTimeout jQuery.ready,
Since setTimeout task belongs to the macro, the macro will jQuery.ready event into the task queue, waiting for the end of the macro task synchronization, will perform.
So, after the completion of redrawing That DOMContentLoaded, will be performed jQuery.ready only wait.

Guess you like

Origin www.cnblogs.com/easonw/p/11505342.html