Last active
December 18, 2017 10:42
-
-
Save theankitgaurav/1b71ce8c7f6b8f206307ae53f5b19d91 to your computer and use it in GitHub Desktop.
Vanilla JS alternative to JQuery's document ready function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callback = function () { | |
// The code to be executed after DOM is ready | |
} | |
if ( document.readyState === "complete" || | |
(document.readyState !== "loading" && !document.documentElement.doScroll) ) { | |
callback(); | |
} else { | |
document.addEventListener("DOMContentLoaded", callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment