wetfish / basic

A tiny, customizable JavaScript UI framework.
MIT License
9 stars 3 forks source link

$(document).ready() never fires if the page is already loaded #28

Open itsrachelfish opened 8 years ago

itsrachelfish commented 8 years ago

Document ready never fires if it is called after the page is already loaded (for example if the script is loaded via require.js).

There are probably other cases where this could happen as well, like if the script file takes a long time to load and it's placed inside the <body>. Not sure, should be tested more thoroughly.

itsrachelfish commented 8 years ago

I guess this could also happen if a document ready function is inside of a setTimeout or setInterval? Not sure why anyone would do that though...

itsrachelfish commented 6 years ago

You can detect the ready state by using https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState