Progo Progo - 1 year ago 130
Javascript Question

Chrome can't load web worker

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 Source

For good reasons, Chrome doesn't let you load web workers when running scripts from a local file. Note: Firefox won't work either. Try Safari. :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download