Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const deferred = new Promise(function(resolve) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
resolve();
}
else {
document.addEventListener('DOMContentLoaded', (/*evt*/) => resolve());
}
});
export default (fn) => deferred.then(fn);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.