From the course: JavaScript: Async
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Creating a web worker - JavaScript Tutorial
From the course: JavaScript: Async
Creating a web worker
- To create a web worker, you use the worker constructor. You assign the worker to a variable, so you can reference it in other parts of your code. The worker constructor requires a single argument, which is a reference to a script file containing the code that should be executed by the worker. When this statement is executed, a new thread is created for the code in the specified file. I've started building out a new feature for the Explorer California site. Users can pick a photo from an image gallery, and then manipulate it using a few photo filters. Eventually, I imagine allowing them to add text, and share the image they've created, like a postcard. But, these basic features represent my first milestone. Each of these filter buttons calls a function that takes the pixels of the current selected image, and modifies them based on the relevant algorithm. Image manipulation can require a significant processing power, and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.