HTML and CSS Reference
In-Depth Information
Web Workers offer interesting potentials to Web Applications: the key is finding the appro-
priate use-cases.
The most viable use-cases are scenarios where the foreground thread can continue to be util-
ized while additional code is executed on the background thread. The foreground thread may
be doing something as trivial as updating a progress bar for the user: but the benefit of Web
Workers is that they will not prevent this happening since they are not hogging the fore-
ground thread.
The other main use-case for Web Workers is algorithms that can naturally be multi-threaded.
In these cases we can spawn multiple Web Workers, and have each of them complete a por-
tion of the algorithm. On devices with multiple cores or processors this is likely to lead to
improved performance. For instance, on a device with 4 cores, a single thread can use at
most 25% of the processing power. If 4 Web Workers were spawned we could theoretically
use 100% of the processing power, and complete the operation 4 times quicker.
Search WWH ::

Custom Search