Skip to content

Instantly share code, notes, and snippets.

@lili21
Created August 12, 2015 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lili21/1cb8a53c6d97899bbf1b to your computer and use it in GitHub Desktop.
Save lili21/1cb8a53c6d97899bbf1b to your computer and use it in GitHub Desktop.
HTMLDocument.prototype.ready = function () {
return new Promise(function(resolve, reject) {
if (document.readyState === 'complete') {
resolve(document)
} else {
document.addEventListener('DOMContentLoaded', function() {
resolve(document)
});
}
});
}
document.ready().then(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment