Chrome can't load web worker

Progo picture Progo · Jan 28, 2014 · Viewed 77k times · Source

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.

Answer

Nobel Chicken picture Nobel Chicken · Apr 22, 2014

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