When the user clicks a button on my webpage, I call a long-running JavaScript function (e.g. the pausecomp function found here: http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm)
The browser freezes while waiting for the function call to finish. How can I make the function run asynchronously? How can I show a throbber while it’s running and hide the throbber when it’s finished?
All examples I’ve found all assume you are using AJAX. Is there a more generic way to do this for any function call?
To make resource-intensive JS processes run ‘asynchronously’, you may want to delegate your long-running function to a web worker. Although support for web worker technology is still incomplete, it’s definitely growing, and allows the browser’s JS engine to leverage multiple execution threads at once so your UI doesn’t hang while numbers are being crunched in the background.
Out of curiosity, what exactly is this long-running process doing?