September 2018
Intermediate to advanced
328 pages
9h 10m
English
Create a new file in the /src directory named index.js and populate it with the following contents:
import WasmWorker from './WasmWorker.js';/** * If you add ?blob=true to the end of the URL (e.g. * http://localhost:8080/index.html?blob=true), the worker will be * created from a Blob rather than a URL. This returns the * URL to use for the Worker either as a string or created from a Blob. */const getWorkerUrl = async () => { const url = new URL(window.location); const isBlob = url.searchParams.get('blob'); var workerUrl = 'worker.js'; document.title = 'Wasm Worker (String URL)'; // Create a Blob instance from the text contents of `worker.js`: if (isBlob === 'true') { const response = await fetch('worker.js'); ...Read now
Unlock full access