pace icon indicating copy to clipboard operation
pace copied to clipboard

Long AJAX request, how to not have bar wait at 99% but progress more gradually?

Open Quantisan opened this issue 12 years ago • 4 comments

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?

Quantisan avatar Aug 22 '14 02:08 Quantisan

I have the exact same question.

yoneth avatar Aug 31 '14 00:08 yoneth

Any update on this?

vijayrajasekaran avatar Mar 14 '15 13:03 vijayrajasekaran

+1

jiMuBao avatar Oct 12 '15 22:10 jiMuBao

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.

CodeByZach avatar Nov 02 '26 01:11 CodeByZach