From the course: JavaScript: Web Workers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Decoding images

Decoding images - JavaScript Tutorial

From the course: JavaScript: Web Workers

Start my 1-month free trial

Decoding images

- [Instructor] An interesting use case for web workers, that is appearing right now on some browsers, is the ability to work with images. Typically, when you have a web page, and in that web page you have an IMG tile, an image, the browser will go to the server, will get that image, let's say for example it's a jpeg file. It's downloading the jpeg file from the server through the network, and then before actually rendering that jpeg file on the screen, it needs to convert that into a bitmap. That's known as the decoding phase. That decoding phase is currently happening in the main thread, which means it's consuming execution in that thread. So for example, if you're also executing other code in a set interval, or if you have some event listeners, then that time to decode the bitmap can be harming the responsiveness of your app. So there is an idea that if the web page creates a web worker, then the web page, instead of loading an image as we are used to, it's going to post a message…

Contents