I do not use jquery, but this may help you.
This is an animated Ajax progress bar with Fake Fallback.
I just pass the fake size knowing the average size of my scripts
therefore, if my scripts are around 50-100 KB, I set the fake size to 150 KB.
if the calculated length is not available, I use a fake size.
In this script, I added an additional check that the size of the bar is always smaller than the container.
just by multiplying the fake size * 2 .. if its smaller than the downloaded data.
to make everything look good, I also added the css3 transition effect so that it delays 700 ms.
this animation delay adds everything you need to make the progress bar real.
copy and paste into the html file and check using a modern browser such as chrome.
replace YOURSITE with ajax content site ... or something else.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Ajax Progress</title> <style> #progress{ width:300px; height:20px; border:1px solid rgba(0,0,0,0.5); } #bar{ width:0%; height:20px; background-color:green; -webkit-transition:width 700ms ease; } </style> <script> var pb, fakeSize=100000,</script> </head> <body> <div id="progress"><div id="bar"></div></div> </body> </html>
you just need to use the progress function in jquery and then set the column to 100% when loading the script.