Last Updated: February 25, 2016
·
133
· malko

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.

https://gist.github.com/malko/c5403a9312e0ffe98fbb