Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<html>
<script>
const workerScript = `
self.onmessage = (e) => {
self.postMessage("Worker is ready.");
};
`;
const blob = new Blob([workerScript], { type: 'text/javascript' });
const blobUrl = URL.createObjectURL(blob);
const worker = new Worker(blobUrl);
function waitForWorker() {
return new Promise(resolve => {
worker.onmessage = resolve;
worker.postMessage("Ping to worker.");
});
}
</script>
</html>