This link says:
Workers may spawn more workers if they wish. So-called sub-workers must be hosted within the same origin as the parent page. Also, the URIs for subworkers are resolved relative to the parent worker's location rather than that of the owning page. This makes it easier for workers to keep track of where their dependencies are.
But when I try to create a Worker
in another Worker
:
var worker = new Worker('foo.js');
I get an exception in Chrome.
Uncaught ReferenceError: Worker is not defined
IE works though (surprisingly). Is this documented somewhere? Is there a proper cross browser way to spawn a Worker
from another Worker
? Doing web search I don't see many (or rather any) code samples of spawning subworkers.
EDIT: Adding some more links:
https://html.spec.whatwg.org/multipage/workers.html#delegation
https://whatwg.org/demos/workers/multicore/page.html (does not work in Chrome)
You are correct. This is a bug. You can find the reported bug here and a polyfill is available here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With