Long AJAX request, how to not have bar wait at 99% but progress more gradually?
I have a AJAX request that takes almost 2 minutes to finish and then it loads the page with the data. The loading bar goes quickly up to 90% and then spends more than a minute at 99% before it finishes correctly with the page. Is there a way to make it progress more gradually along with that one big ajax call?
I have the exact same question.
Any update on this?
+1
Thanks for asking. Pace can't see how far along the server is, so while a request is pending it eases toward 100% and then waits near 99% until the response arrives. You can slow that easing with the initialRate option (default 0.03, in percent per millisecond), set before pace.js loads:
<script>window.paceOptions = { initialRate: 0.003 };</script>
<script src="pace.min.js"></script>
In a quick test with one slow request, the bar was around halfway after 8 seconds with 0.003, compared with about 97% with the default. Tune it to your typical wait. It applies to every load, and the bar still jumps to 100% as soon as everything finishes.
If this still happens on the latest version, comment here and we'll take another look.