JSFiddle - React, Tailwind, and code Playground

by noblood

JavaScript

// ON TEST HTML5 JavaScript //

// Establish two-way communications between the web worker process and the page.
// From the main page, use the onmessage event handler of the web worker to caputure events.
// From the web worker, use the onmessage event handler of the main page to caputure events.

/*
// External workers dowork.js
onmessage = function(e) {
    postMessage(e.data);   
}
*/

// Inline workers
var blob = new Blob(["onmessage = function(e) { postMessage(e.data); }"]);
var blobURL = window.URL.createObjectURL(blob);

// Main page
var worker = new Worker(blobURL);
worker.onmessage = function(e) {
    alert(e.data);
};
worker.postMessage("hello"); // Start the worker.