If you're like me and wanted to serve your main app script from a CDN and still load a web worker, you may have encountered the following error:
Uncaught DOMException: Failed to construct 'Worker': Script at 'http://cdn.example.com/worker.js' cannot be accessed from origin 'http://example.com'
You can get around this fairly simply with importScripts by making the script you instantiate your worker with load the actual worker script from the CDN.
You can play with the following example by running two web servers to serve these files.
ie: python -m SimpleHTTPServer 9000
and one on 9001
.
Then, visit localhost:9000 in your browser (open the developer tools).
This also works with inline workers (see main-inline.js).