Created
February 4, 2021 17:10
-
-
Save bartwttewaall/db3dc9ca05ec30b3ed3c425deba69477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function domReady(callback) { | |
if (['interactive', 'complete'].includes(document.readyState)) { | |
callback(); | |
} else { | |
document.addEventListener('DOMContentLoaded', callback); | |
} | |
} | |
domReady(() => { | |
if (!document.body) return; | |
console.log('dom is ready, init something...'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment