As stated in this thread: window.onload vs $(document).ready(). The window.onload
should occur later than the $(document).ready()
but in this simple co
The problem is not with the order of the events. It with the jQuery wrapper around the native DOM events. If you try the native DOMContentLoaded
you will find that it always runs before window.onload
. But the jQuery event
$(document).ready
will come some milliseconds after DOMContentLoaded
, which in some cases might be after window.onload
too, especially if the page doesn't have much to load like the code below. This is delay is due to jQuery implementation.
If you uncomment the iframe in the code though, it takes some time to load which causes the window.onload
to be delayed, so $(document).ready
will come first.
A Simple Site