Chrome can't load web worker

google-chrome, javascript, web-worker

Solution

Chrome doesn't let you load web workers when running scripts from a local file.

Problem

I am working on a project that uses a web worker. In my head section I have this code: ``` var worker = new Worker("worker.js"); // More code ``` This works fine in Safari, but Chrome reports the following error: `Uncaught SecurityError: Failed to create a worker: script at '(path)/worker.js' cannot be accessed from origin 'null'.` Why does this work perfectly in Safari but not Chrome? How do I fix this? Thank you.

Original source

Related problems