Unable to create stockfish object
I loaded stockfish through a script tag. Now, when I use var stockfish = new STOCKFISH(), I get the error:
on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)
and also
failed to compile wasm module: abort("on the web, we need the wasm binary to be preloaded and set on Module['wasmBinary']. emcc.py will do that for you when generating HTML (but not JS)") at Error
I'm loading a local stockfish.js script into a local html file. I have also tried loading from a web server. Anyone know what's up?
You're right, the WASM version seems to have broken the script tag option. That might be fixable by compiling it with different flags. I'm not sure.
But it's better to use a Web Worker anyway since it offloads work onto another process.
You can load Stockfish as a Web Worker like so:
var stockfish = new Worker("stockfish.js");
stockfish.onmessage = function onmessage(event) {
console.log(event.data);
};
stockfish.postMessage("go depth 15");
Web Workers do require a web server though.