ImFusion Web SDK

preloadWasm

ts
function preloadWasm(options?: { url?: string | URL; priority?: RequestPriority }): Promise<Module>;

Fetch and compile the SDK's WebAssembly module ahead of init.

The compiled module is cached at the SDK module level. Calling preloadWasm() more than once returns the same cached promise; subsequent calls to init pick up the cached module automatically.

Parameters

ParameterTypeDescription
options?{ url?: string | URL; priority?: RequestPriority; }-
options.url?string | URLURL to fetch the wasm from. Defaults to the wasm co-located with the SDK.
options.priority?RequestPriorityFetch priority hint. Use 'low' for background preloading.

Returns

Promise<Module>

A promise that resolves to the compiled WebAssembly.Module.

Example

ts
// main.ts - kick off the wasm fetch as early as possible.
import { preloadWasm } from '@imfusion/sdk';
preloadWasm();

// Later, in a component
import { init } from '@imfusion/sdk';
const imf = await init(canvas);