Skip to content

Instantly share code, notes, and snippets.

@MiguelCastillo
Created January 10, 2018 17:27
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 MiguelCastillo/deba8c06df41cdefd6eb7a4a158472e2 to your computer and use it in GitHub Desktop.
Save MiguelCastillo/deba8c06df41cdefd6eb7a4a158472e2 to your computer and use it in GitHub Desktop.
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