I have a script at http://localhost/js/foo.js
which needs to spawn a Web Worker from the file http://localhost/js/fooWorker.js
. I assumed I could just do something like this:
var worker = new Worker('fooWorker.js')
However, this results in a 404 error, as the browser cannot find http://localhost/fooWorker.js
. I was under the impression that worker paths were resolved relative to the script spawning the worker, so shouldn't I just be able to specify the name of another .js file in the same directory without having to provide an absolute path? Am I doing something wrong?
From http://www.w3.org/TR/workers/:
When the Worker(scriptURL) constructor is invoked, the user agent must run the following steps:
- Resolve the scriptURL argument relative to the entry script's base URL, when the method is invoked.
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