JA EN

Web Worker

A browser mechanism for running JavaScript in background threads separate from the main UI thread, preventing interface freezes during heavy image processing.

Web Workers provide a multithreading mechanism in browsers, executing JavaScript on background threads independent of the main (UI) thread. By offloading computationally intensive pixel manipulation and filter operations to workers, the interface remains responsive.

Data exchange between the main thread and workers uses postMessage(). Large buffers like ImageData can be sent as Transferable Objects, transferring ownership rather than copying to minimize overhead.

The batch compression tool spawns multiple Web Workers in parallel, processing each image in an independent worker for improved throughput. Combined with OffscreenCanvas, workers can perform Canvas API drawing directly, fully decoupling image processing from the main thread.

Related Terms

Related Articles