As I know, jQuery ready
handler can sometimes fire after the load
event if the load
event fires quickly enough.
I'm trying to resolve this ambiguity. So, I want to be sure that ready
fires first and load
second, under all circumstances.
Here is my attempt:
$(document).ready(function() {
console.log('Ready comes first');
});
$(window).on('load', function() {
$.ready.then(function() {
console.log('Onload comes second');
});
});
Is it correct? Probably I missed something?
Edit: And now Royi Namir says that load
almost everytime will hit first (i.e. before ready
), altough I tend to think vice versa. Now I do not understand anything.