blob: ee89a0d8b3ee7513ff3817632db32a9f5f2c162a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<!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>
|