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
| Parameter | Type | Description |
|---|---|---|
options? | { url?: string | URL; priority?: RequestPriority; } | - |
options.url? | string | URL | URL to fetch the wasm from. Defaults to the wasm co-located with the SDK. |
options.priority? | RequestPriority | Fetch priority hint. Use 'low' for background preloading. |
Returns
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);