Create a Worker from a cross-origin URL using Blob URL workaround.
Browsers block creating Workers from cross-origin scripts (like those served from CDNs). This function fetches the worker script and creates a same-origin Blob URL from it.
URL to the worker script (can be cross-origin)
Promise resolving to a same-origin Worker
import { createWorker, getJsDelivrBundle, init } from '@ducklings/browser';const bundle = getJsDelivrBundle();const worker = await createWorker(bundle.mainWorker);await init({ worker }); Copy
import { createWorker, getJsDelivrBundle, init } from '@ducklings/browser';const bundle = getJsDelivrBundle();const worker = await createWorker(bundle.mainWorker);await init({ worker });
Create a Worker from a cross-origin URL using Blob URL workaround.
Browsers block creating Workers from cross-origin scripts (like those served from CDNs). This function fetches the worker script and creates a same-origin Blob URL from it.