# prepareLayoutEngine

```ts
import { prepareLayoutEngine } from "@pibbl/core";

await prepareLayoutEngine();
```

`prepareLayoutEngine(): Promise<void>` fetches and compiles the external generated
layout WASM asset. It creates no mount, instance, arena, signal subscription or
animation frame. Concurrent callers share one attempt. A ready compatible module
is reused by both [pibbl](/reference/functions/pibbl/) and
[pibblSync](/reference/functions/pibbl-sync/).

A failed fetch, HTTP response, fingerprint check or compilation rejects with asset
and phase context. The failed attempt is evicted; a later call can retry. This
operation has no cancellation argument because it warms shared immutable code.
A mount can cancel its own wait through `PibblConfig.signal`.

Importing the package does not fetch or compile the engine. HTML preload with
matching URL and credentials can warm the network cache independently; it does not
compile WASM. Serve the emitted `.wasm` asset with the application, including its
deployment base path, with `application/wasm` MIME type. Fingerprint verification
uses Web Crypto, so deploy over HTTPS or a trusted localhost origin. External fetch follows normal CORS requirements; CSP must
permit the fetch and WebAssembly compilation. The asynchronous entry excludes the
separate embedded binary payload.

## API details from source

<span id="api-prepareLayoutEngine"></span>

Fetches and compiles the external layout WASM ahead of mounting. Concurrent
calls share one attempt; a later call retries after failure. Creates no mount.
HTML preload can independently warm the network cache.

```ts
prepareLayoutEngine: () => Promise<void>
```

Related API: [prepareLayoutEngine](/reference/functions/prepare-layout-engine/).

### Returns

A Promise fulfilled when the compatible compiled module is ready.

### Throws

Rejects on fetch, integrity or compilation failure, with the original cause.

### See also

[pibbl](/reference/functions/pibbl/)

[View source — packages/core/src/lib/pibbl.ts:15](/source/packages/core/src/lib/pibbl-ts/#L15)

## Implementation guidance for agents

Read the [Drawing, layout, and effects companion](/agents/topics/layout/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Prepare layout before mounting](/minimal-examples/lifecycle/prepare-layout-engine/): Warm the shared layout module before creating an asynchronous canvas mount. [Plain source](/minimal/lifecycle/prepare-layout-engine.tsx)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.
