Ducklings API Documentation
    Preparing search index...

    Function createWorker

    • 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.

      Parameters

      • url: string

        URL to the worker script (can be cross-origin)

      Returns Promise<Worker>

      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 });