So you put your complicated computation in Web Workers, but you just realized the computation is not that complicated at all. Also, you denied the browsers without web workers to ever running your hard work – Mobile Safari, all IEs up to version 9.
Here is the solution I took, something might be useful to you: Simulated Web Workers – a library that creates a pseudo-web worker (that runs at fore-ground), while expose the same interfaces. Well, almost.
By almost, I mean the following:
- Instead of calling
postMessage()to send the result, in IE you must call
workerPostMessage()– because IE doesn’t allow me to overwrite the aforementioned function.
while(true)example given by Wikipedia won’t work. The
setTimeout()trick however would make it work again (in a not-so-efficient way) – please check the library tests.
You could say Simulated Web Workers is like exCanvas for canvas, but of course the interfaces of web workers are not that many. Anyway, have fun with your next web workers project.