Created
August 12, 2014 09:49
-
-
Save malko/c5403a9312e0ffe98fbb to your computer and use it in GitHub Desktop.
shortest cross platform onReady document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* very poor (but short and easy) cross platform implementation to detect dom readiness | |
*/ | |
function onReady(fn){ | |
document.body ? fn() : setTimeout(function(){ onReady(fn);},50); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not really a dom ready but is sufficient most of the time if all you need is ensure a body element is already present in the document.