I have been adding logs to the console to check the status of different variables without using the Firefox debugger.
However, in many places in which I add a
Sometimes it's necessary to ajax load a script but delay document ready until after the script is loaded.
jQuery supports this with the holdReady()
function.
Example usage:
$.holdReady(true); //set hold
function releaseHold() { $.holdReady(false); } //callback to release hold
$.getScript('script.js', releaseHold); //load script then release hold
The actual script loading is asynchronous (no error), but the effect is synchronous if the rest of your JavaScript runs after document ready.
This advanced feature would typically be used by dynamic script loaders that want to load additional JavaScript such as jQuery plugins before allowing the ready event to occur, even though the DOM may be ready.
Documentation:
https://api.jquery.com/jquery.holdready
From JQMIGRATE:
jQuery.holdReady() is deprecated
Cause: The
jQuery.holdReady()
method has been deprecated due to its detrimental effect on the global performance of the page. This method can prevent all the code on the page from initializing for extended lengths of time.Solution: Rewrite the page so that it does not require all jQuery ready handlers to be delayed. This might be accomplished, for example, by late-loading only the code that requires the delay when it is safe to run. Due to the complexity of this method, jQuery Migrate does not attempt to fill the functionality. If the underlying version of jQuery used with jQuery Migrate no longer contains
jQuery.holdReady()
the code will fail shortly after this warning appears.