Nutrient Web SDK

Function preloadWorker

Preloads the standalone WASM worker.

In cases where you don't want to load a PDF right away, the first invocation of NutrientViewer.load after allowing this function to resolve will be significantly faster.

If NutrientViewer.load is called while this function has not yet resolved, then NutrientViewer.load will simply reuse the request from this function without adding any overhead.

FunctionStandalone
Type Signature
preloadWorker(configuration: StandaloneConfiguration): Promise<void>
  • Standalone

    Type Declaration

    Parameters

    A configuration Object

    Returns

    Promise<void>

    Promise that resolves when preloading is complete

    Example

    // Fetches worker asynchronously
    NutrientViewer.preloadWorker(configuration);
    document.querySelector("#open-pdf-button").addEventListener(async () => {
    await NutrientViewer.load({ ...configuration, document: "my-doc.pdf" });
    });