Skip to content

Instantly share code, notes, and snippets.

@JoshuaKGoldberg
Created December 18, 2016 05:49
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 JoshuaKGoldberg/aad012656d267a940f67df5096ae4d31 to your computer and use it in GitHub Desktop.
Save JoshuaKGoldberg/aad012656d267a940f67df5096ae4d31 to your computer and use it in GitHub Desktop.
NProgress and RequireJS with onResourceLoad
// Start showing a progress bar
NProgress.start();
// Tell the user whenever we make progress
requirejs.onResourceLoad = () => NProgress.inc());
// Send a network request, and when it's done, hide the bar
sendNetworkRequest().then(() => {
NProgress.stop();
delete requirejs.onResourceLoad;
doOtherWork();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment