CREATE A WEB WORKER JAVASCRIPT FILE

Using Web Workers in HTML5 is a very easy way to add in a level of optimization that was not possible a few short years ago. Previously, JavaScript could run in only one thread in the browser, and any CPU-intensive tasks bogged down user interface features. When you split up your CPU-intensive code into a Web Worker JavaScript file, your users can continue using your website while the Web Worker asynchronously works.

To convert existing JavaScript code into Web Worker code, you need to create a conduit that allows for subroutines to be executed by way of event messages. The parent JavaScript thread running in the browser window will send event messages to a listener running on your Web Workers, and they in ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications 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.