Chapter 27APIs: Web Workers
Every HTML5 app is written in JavaScript, but the single and the most
crucial limitation of HTML5 apps is that the browsers’ JavaScript runtimes
are single-threaded in nature. Some of you might say
that you have run tasks asynchronously in the past using functions like
setTimeout
, setInterval
, and our
all-time favorite, XMLHttpRequest
. But, in reality, those
functions are just asynchronous, not concurrent. Actually, all JavaScript
tasks run one after the other and are queued accordingly. Web Workers offer
us a multi-threaded environment where multiple
threads can execute in parallel, offering true concurrency.
In this chapter, we’ll first discuss the purpose and how to use Web Workers, before having a look at some ...
Get Jump Start HTML5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.