14 lines
321 B
HTML
14 lines
321 B
HTML
<script>
|
|
function loadWorker(url) {
|
|
return new Promise((resolve) => {
|
|
try {
|
|
const w = new Worker(url);
|
|
w.onerror = () => resolve('failed');
|
|
w.onmessage = (m) => resolve(m.data);
|
|
w.postMessage('success');
|
|
} catch {
|
|
resolve('failed');
|
|
}
|
|
});
|
|
}
|
|
</script>
|