Skip to content

Instantly share code, notes, and snippets.

@shgysk8zer0
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save shgysk8zer0/a2133eabc4d8caabec25 to your computer and use it in GitHub Desktop.

Select an option

Save shgysk8zer0/a2133eabc4d8caabec25 to your computer and use it in GitHub Desktop.
document.ready
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Document.Ready?</title>
<script>
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(() => alert('ready'));
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment