Skip to content

Instantly share code, notes, and snippets.

@vaporwavie
Last active May 6, 2020
Embed
What would you like to do?
Document is literally ready
const DOMisReady = (handler: () => void) => {
if (document.readyState !== "loading") {
handler();
} else {
document.addEventListener("DOMContentLoaded", handler);
}
}
// Usage
DOMisReady(() => {
// do your magic
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment