Reputation: 35194
Would it be ok to add an ajaxStop()
event handler to the document
before the DOM is loaded? It isn't related to any DOM elements, so as far as I can tell it shouldn't matter. Am I right?
$(document).ajaxStop(function () {
console.log('ajax complete');
});
vs
$(function(){
$(document).ajaxStop(function () {
console.log('ajax complete');
});
});
Upvotes: 0
Views: 50
Reputation: 227190
$(function(){})
is actually shorthand for $(document).ready(function(){})
.
So, by using $(function(){})
you already are binding an event to document
before the DOM is ready.
By that logic, it's fine to bind ajaxStop
to document
before the DOM is ready.
Upvotes: 1