function docReady(fn) {
    // see if DOM is already available
    if (document.readyState === "complete" || document.readyState === "interactive") {
        // call on next available tick
        setTimeout(fn, 1);
    } else {
        document.addEventListener("DOMContentLoaded", fn);
    }
}
// On document ready with vanilla js
On document ready with vanilla js
On document ready with vanilla js
function docReady(fn) {
    if (document.readyState === "complete" || document.readyState === "interactive") {
        setTimeout(fn, 1);
    } else {
        document.addEventListener("DOMContentLoaded", fn);
    }
}
function docReady ( fn ) { if ( document . readyState === "complete" || document . readyState === "interactive" ) { setTimeout ( fn , 1 ) ; } else { document . addEventListener ( "DOMContentLoaded" , fn ) ; } }
On document ready with vanilla js
On document ready with vanilla js
// see if DOM is already available // call on next available tick