4 ms·
I got over that limitation by converting the code to a data URL, like this: var blob = new Blob([worker_code_string], {type: 'application/javascript'});
by DiThi 11y ago
I got over that limitation by converting the code to a data URL, like this:
var blob = new Blob([worker_code_string], {type: 'application/javascript'});
var worker_uri = (window.URL || window.webkitURL).createObjectURL(blob);
var worker = new Worker(worker_uri);
The path to the scripts imported with importScript() must be absolute, though. I add the path by modifying worker_code_string. Alternatively they can be fetched and prepended to the code string (or passed in the array of Blob()).
- Kequc 11y agoI was reading about that. It seems pretty strange that these heavy security restrictions on origin are in place but you can create a worker from a string.