Skip to content

Instantly share code, notes, and snippets.

@malko
Created August 12, 2014 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malko/c5403a9312e0ffe98fbb to your computer and use it in GitHub Desktop.
Save malko/c5403a9312e0ffe98fbb to your computer and use it in GitHub Desktop.
shortest cross platform onReady document
/**
* very poor (but short and easy) cross platform implementation to detect dom readiness
*/
function onReady(fn){
document.body ? fn() : setTimeout(function(){ onReady(fn);},50);
};
@malko
Copy link
Author

malko commented Aug 12, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment