Create a long run function using setTimeout:
function domUpdateDelayExperiment() { tellViewerLoading(); setTimeout(someActionThatTakesALongTime, 50); }
Explanation: The tellViewerLoading() function updates the DOM, but the browser will not display the changes on the screen until domUpdateDelayExperiment() returns. someActionThatTakesALongTime with setTimeout (), we allow the browser to reflect DOM changes. The timeout is arbitrary, but its minimum value may be important in some browsers. The value of 50 ms is fairly fair.
source share