script-progress | Estimate script execution time | Build Tool library
kandi X-RAY | script-progress Summary
kandi X-RAY | script-progress Summary
Estimate script execution time
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of script-progress
script-progress Key Features
script-progress Examples and Code Snippets
Community Discussions
Trending Discussions on script-progress
QUESTION
I have a loop that processes data for a while, so I'd like to show a progress bar while the loop is processing. I've tried updating the progress bar within each loop iteration:
...ANSWER
Answered 2020-Jun-19 at 21:09Long running loops in JS freezes the UI refresh, to show the progress of data, you may need to move the data processing logic to web worker. You can read about web worker on the following link.
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
QUESTION
I've been reading about the single-thread nature of javascript and how the UI will not update until the code is complete (eg. this question). The responses to that question mainly explained how the code executes, but didn't provide a real viable solution outside of some "hacky" timers.
I'm wondering if there is a good solution, that may include promises, or .then()
functionality that will "paint" the UI prior to javascript execution.
The following is a specific example: http://jsfiddle.net/zbtsd12k/. In this example I would expect the "Change Color" to change immediately, prior to the calculation being run.
WARNING: My example includes a for-loop of one billion iterations (which took < 2 seconds on my machine) and may freeze your computer for a bit.
Any help would be appreciated.
...ANSWER
Answered 2019-Jan-02 at 17:40A few changes
- Added a
setTimeout
around the "logic" so that the DOM has a chance to redraw - Broke apart the
then(makeCalculations())
line because #1updateClass()
does not return a promise and #2then(methodCall())
would execute the methodCall immediately because you put()
on the end of it.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install script-progress
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page