This question was already asked. The workers should work in HTML files opened from disk as long as you use relative path. However, if chrome implements this correctly has been disputed.
I advise that you try to use relative path in your scripts:
new Worker("./scripts/worker.js");
If that doesn't work, see this workaround: https://stackoverflow.com/a/33432215/607407
Specifically, load worker as a function, then convert the function to string:
function worker_function() {
// all worker code here
}
var worker = new Worker(URL.createObjectURL(new Blob(["("+worker_function.toString()+")()"], {type: 'text/javascript'})));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…