HTML5 Guidelines for Web Developers

(coco) #1

10 Web Workers


If you have already been experimenting a bit with JavaScript, you may have come
across a browser message similar to this: A script on this page may be busy, or it
may have stopped responding. This could be the result of a programming error,
perhaps an endless loop. But what should you do if your JavaScript does not have
an error and the calculation is just taking a bit longer than usual? This is where
web workers come in.


10.1 Introduction to Web Workers...............................................................


To ensure that long calculations on the client side do not block the browser, a
worker can work in the background and inform the calling script about the status
of its calculations via messages. Workers have no access to DOM APIs, the window


249
Free download pdf