Why do I keep getting this error?
I should be able to use this global function right?
http://www.html5rocks.com/en/tutorials/workers/basics/
I\'m usi
I encountered this error as well. In my case, it is because I am testing the code using Karma/Jasmine. Due to the test framework, the worker.js file is loaded by main thread as well.
I avoided this error by wrappig the worker.js file with:
if( 'undefined' === typeof window){
importScripts('workerscript2.js');
...
}
Please refer to the comment below by Rob, which offers an alternative solution.