Skip to content

Instantly share code, notes, and snippets.

@gandhiShepard
Created September 30, 2015 20:29
Show Gist options
  • Save gandhiShepard/95955a1ee7040e786c61 to your computer and use it in GitHub Desktop.
Save gandhiShepard/95955a1ee7040e786c61 to your computer and use it in GitHub Desktop.
DOM Ready vanilla JS
// DOMReady function
// Can't remember where I found this...
// I'll add attributes later
var domReady = function(callback) {
document.readyState === "interactive" || document.readyState === "complete" ? callback() : document.addEventListener("DOMContentLoaded", callback);
};
domReady(function() {
console.log( 'What up! This DOM is ready yo!' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment