Create a gist now

Instantly share code, notes, and snippets.

@tvler /onwheneva.js
Last active May 11, 2016

What would you like to do?
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