I found code in my codebase that has $(document).ready(function() {...}
inside of another $(document).ready(function() {...}
e.g.
$(document).ready(function() {
// 20 lines...
$(document).ready(function() {
foo()
}
// 200 lines...
}
function foo() {...}
I want to understand the order of execution so I can safely refactor out this nested callback. The outer callback seems to continue executing before the inner callback executes. Is the outer callback guaranteed to finish before the inner callback gets called?
ready
event after the event has fired? I would have expected that code (within the outer function) to never execute. – Cadastredocument.ready
callback and the originaldocument.ready
code was left as-is. Thankfully things kept working because that would have been a nightmare to debug. – Prentice