Question

This question has been asked and answered here and here. However, both threads are 18+ months old and things are evolving rapidly in the javascript world. So I'm asking again to get an up to date answer.

For our use we need a single background thread that will be running pretty regularly. It's for a rich editor and whenever the user edits, this background thread needs to recalculate the layout of the rich text.

It looks like Web Workers are the best approach. However, according to wikipedia "It is removed in newer Android browser versions".

Questions:

  1. Are Web Workers the best approach or is there something better.
  2. Are there browsers that are not going to support Web Workers going forward? And if so, which ones?
  3. Is there a list of what version of the main browsers are required for Web Workers?
Was it helpful?

Solution

I would recommend WebWorkers as your first option.

True, they were removed from Android in 2.2, but were also re-added in 4.4 and are now supported by the latest version of all major platforms. See http://caniuse.com/webworkers to see in which version WebWorkers are available.

For browsers without support for WebWorkers I would recommend a fallback with postMessage() or setTimeout(), as detailed in Javascript - how to avoid blocking the browser while doing heavy work?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top