optimization: when NProgress.inc() and/or NProgress.set() are invoked with high frequency and the same 'progress value', then it's no use to re-render/update the DOM: that will slow us down even more in an already suboptimal usage pattern. The caller would be best served by inspecting his calling process here, but meanwhile we can very easily lighten the burden -- without the optimization NProgress.set() will spend a *lot* of time in the browser's DOM engine via querySelectorAll() and HTMLElement.offsetWidth (--> trigger DOM reflow/layout action).
optimization: when NProgress.inc() and/or NProgress.set() are invoked with high frequency and the same 'progress value', then it's no use to re-render/update the DOM: that will slow us down even more in an already suboptimal usage pattern. The caller would be best served by inspecting his calling process here, but meanwhile we can very easily lighten the burden -- without the optimization NProgress.set() will spend a *lot* of time in the browser's DOM engine via querySelectorAll() and HTMLElement.offsetWidth (--> trigger DOM reflow/layout action).

Numbers from actual profile run in user app:
97 seconds spent in NProgress.inc/set @ get offsetWidth --> except for a few milliseconds, all time in .set()/.inc() is spent in the DOM, i.e. the browser's layout/render engine
9.1 seconds spent in NProgress.inc/set @ querySelectorAll --> these are the high number of II.findElementByAny() calls kicking in as .set() is invoked with very high frequency.
which consumes a total of ~100 seconds, while the app itself consumed a similar amount of time elsewhere.

After this optimization, NProgress.set() drops to 1.3 seconds total cost: all spent in 'get offsetWidth' while querySelectorAll doesn't feature in the profile anymore (mostly due to the user app having a *huge* DOM tree hence reflow/layout is always a high cost).

GerHobbelt/nprogress,GerHobbelt/nprogress,GerHobbelt/nprogress