Created
July 22, 2017 13:50
-
-
Save bradoyler/967198e62fbb21bf40c86e3f31e1c57d to your computer and use it in GitHub Desktop.
dom ready function for modern browsers
This file contains 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) { | |
function handler () { | |
document.removeEventListener('DOMContentLoaded', handler, false) | |
window.removeEventListener('load', handler, false) | |
callback() // may pass parent context here | |
} | |
document.addEventListener('DOMContentLoaded', handler, false) | |
window.addEventListener('load', handler, false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment