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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2011 Peter Lubbers, Brian Albers, and Frank Salim
About this chapter
Cite this chapter
Lubbers, P., Albers, B., Salim, F. (2011). Using the Web Workers API. In: Pro HTML5 Programming. Apress. https://doi.org/10.1007/978-1-4302-3865-2_10
Download citation
DOI: https://doi.org/10.1007/978-1-4302-3865-2_10
Publisher Name: Apress
Print ISBN: 978-1-4302-3864-5
Online ISBN: 978-1-4302-3865-2
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books