O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required