Skip to content

Instantly share code, notes, and snippets.

@denis-shvets
Created July 12, 2015 10:38
Show Gist options
  • Save denis-shvets/c4fd5326b6a8bd80e25d to your computer and use it in GitHub Desktop.
Save denis-shvets/c4fd5326b6a8bd80e25d to your computer and use it in GitHub Desktop.
dom.ready
var domReady = function(callback) {
if(callback && typeof callback === 'function') {
if(!document.attachEvent || typeof document.attachEvent === 'undefined') {
document.addEventListener('DOMContentLoaded', function() {
return callback();
});
} else {
document.attachEvent('onreadystatechange', function() {
if(document.readyState === 'complete') {
return callback();
}
});
}
} else {
// Do something else
}
};
domReady(function() {
//
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment