Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jQuery Dom ready equivalent in pure JavaScript

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);
    }
}    
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jQuery #Dom #ready #equivalent #pure #JavaScript
ADD COMMENT
Topic
Name
4+7 =