Slim progress bars for Ajax'y applications. Inspired by Google, YouTube, and Medium.
$ bower install --save nprogress $ npm install --save nprogress
done() to control the progress bar.
Add progress to your Ajax calls! Bind it to the jQuery
Make a fancy loading bar even without Turbolinks/Pjax! Bind it to
Percentages: To set a progress percentage, call
.set(n), where n is a
NProgress; // Sorta same as .start()NProgress;NProgress; // Sorta same as .done()
Incrementing: To increment the progress bar, just use
increments it with a random amount. This will never get to 100%: use it for
every image load (or similar).
If you want to increment by a specific value, you can pass that as a parameter:
NProgress; // This will get the current status value and adds 0.2 until status is 0.994
Force-done: By passing
done(), it will show the progress bar
even if it's not being shown. (The default behavior is that .done() will not
do anything if .start() isn't called)
Get the status value: To get the status value, use
Changes the minimum percentage used upon starting. (default:
You can change the markup using
template. To keep the progress
bar working, keep an element with
role='bar' in there. See the default template
Adjust animation settings using easing (a CSS easing string)
and speed (in ms). (default:
Turn off the automatic incrementing behavior by setting this to
You can adjust the trickleRate (how much to increase per trickle) and trickleSpeed (how often to trickle, in ms).
Turn off loading spinner by setting it to false. (default:
specify this to change the parent container. (default:
nprogress.css to your liking. Tip: you probably only want to find
and replace occurrences of
The included CSS file is pretty minimal... in fact, feel free to scrap it and make your own!
- New UI Pattern: Website Loading Bars (usabilitypost.com)