Skip to content

Instantly share code, notes, and snippets.

@theankitgaurav
Last active December 18, 2017 10:42
Show Gist options
  • Save theankitgaurav/1b71ce8c7f6b8f206307ae53f5b19d91 to your computer and use it in GitHub Desktop.
Save theankitgaurav/1b71ce8c7f6b8f206307ae53f5b19d91 to your computer and use it in GitHub Desktop.
Vanilla JS alternative to JQuery's document ready function
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