Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Created July 22, 2017 13:50
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 bradoyler/967198e62fbb21bf40c86e3f31e1c57d to your computer and use it in GitHub Desktop.
Save bradoyler/967198e62fbb21bf40c86e3f31e1c57d to your computer and use it in GitHub Desktop.
dom ready function for modern browsers
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