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);
};
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.
Written by Jonathan Gotti
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Related Tags
#javascript
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#