Experiment 01 · Worker instantiation · Embedded script

Uses a embedded script (as a Blob), that simply acknowledges messages it receives, logging them on the console. Embedded script instantiated with:

const workerBlob = new Blob( [`self.onmessage = (msg) => { … };`]);
const workerBlobURL = window.URL.createObjectURL( workerBlob);
const worker = new Worker( workerBlobURL);
worker.postMessage( { op: "sip", args: [ "☕️" ] });
worker.postMessage( { op: "crunch", args: [ "🍐", "🍪" ] });
worker.postMessage( { op: "listen", args: [ "Jaco / Portrait of Tracy" ] });
worker.postMessage( { op: undefined });

Open the Console (CMD-ALT-J), which should display an output similar to this one:

Supported by Safari 12 and Firefox 64 and Chrome 71 out-of-the box.