I have been trying to create a loading bar during a very intense JavaScript period where some rather heavy 3D arrays are created and populated. This boot panel should remain blank until the user clicks a button.
Freezing occurs regardless of whether I -webkit-transition (this application can be chrome-exclusive, a cross browser is not needed in my case).
In search of simplicity, I built my bar like this ...
<div id="loader"> <div id="thumb"> </div> </div>
... and then tried to increase this bar at different stages of my main for loop:
for(i = 0; i < 5 ; i++){ document.getElementById('thumb').style.width = i*25 + '%';
The problem is that everything freezes until JavaScript ends. I found a similar question about stack overflow, Using CSS animations when calculating javascript , as well as in the comments found and reviewed, and / or tried the following:
Web workers
Do not think that this will work, as my script fills the array with objects and constructors containing functions that according to this site will not work
JQuery
Not an option, I can’t use external libraries in my application - in any case, importing an entire library just for the loading bar seems kind of redundant ...
Keyframes
It was promising, and I tried, but in the end it also freezes, so no joy
timeOut() s
Thinking about it, but since the loading bar dot is a reduction in frustration, increasing the latency seems counterproductive
I would be glad if at this stage there was any increase in the bar, even if it was not smooth! I'm sure this is a problem that has struck me more than anyone, maybe someone has an interesting solution?
PS: I am posting this as a new question, and am not adding to the question, as I am specifically looking for help with JavaScript (not jQuery) and would prefer it if I could get it using the transition (! = Animation) in width.
source share