Skip to content

Instantly share code, notes, and snippets.

@tvler
Last active May 11, 2016 01:51
Show Gist options
  • Save tvler/8fd53d11ed775ebc72419bb5d96b8696 to your computer and use it in GitHub Desktop.
Save tvler/8fd53d11ed775ebc72419bb5d96b8696 to your computer and use it in GitHub Desktop.
A way to call a JavaScript function on DOMContentLoaded or after, no rush. Great for non-essential async code.
var test = () => {
console.log('fired on DOMContentLoaded or after');
}
window.onwheneva = test;
document.readyState !== 'loading' ? onwheneva() :
document.addEventListener('DOMContentLoaded', onwheneva);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment