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.