JQuery. HoldReady of

  • 2020-03-30 03:02:05
  • OfStack

holdReady: function( hold ) { 
if ( hold ) { 
jQuery.readyWait++; //ReadyWait is a counter that indicates how many more entry ready events are available to execute

} else { jQuery.ready( true ); } } 


JQuery. HoldReady (hold)

Action: suspends or restores the execution of the. Ready () event

Parameter: hold is a Boolean value indicating whether to pause or resume the requested ready event

The jquery.holdready () method allows the completion events of jQuery to be locked by the function. A typical use of this advanced feature is to dynamically load scripts, such as jQuery plug-ins. JQuery completion events are not triggered until additional scripts are loaded, even if the page is ready. This function must be called at the top of the page, such as in < Head> In the tag, jQuery loads the next line. Calling this function after the completion event has been triggered has no effect. How to use: first call $.holdready (true)[the completion event is locked after the call]. When you are ready to fire the completion event, call $.holdready (false). Note that you can add multiple locks to the completion event, with each lock corresponding to a $.holdready (false)[unlock] call. JQuery's completion event is triggered when all locks are lifted and the page is ready. This is essentially a security lock for some code that relies on dynamic scripts and executes the ready event after the required dynamic scripts are loaded, rather than after a successful DOM tree build.

Related articles: