Advertisement

Using the Web Workers API

  • Peter Lubbers
  • Brian Albers
  • Frank Salim

Abstract

JavaScript is single-threaded. As a result, long-lasting computations (not necessarily due to poorly written code) will block the UI thread and make it impossible to add text to text boxes, click buttons, use CSS effects, and, in most browsers, open new tabs until control has returned. As an answer to that problem, HTML5 Web Workers provide background-processing capabilities to web applications and typically run on separate threads so that JavaScript applications using Web Workers can take advantage of multicore CPUs. Separating long-running tasks into Web Workers also avoids the dreaded slow-script warnings, shown in Figure 10-1, that display when JavaScript loops continue for several seconds.

Keywords

Incoming Message Main Page Stop Worker Event Listener Window Object 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Peter Lubbers, Brian Albers, and Frank Salim 2011

Authors and Affiliations

  • Peter Lubbers
  • Brian Albers
  • Frank Salim

There are no affiliations available

Personalised recommendations