# Prepare layout before mounting
Warm the shared layout module before creating an asynchronous canvas mount.

## APIs demonstrated

- [prepareLayoutEngine](/reference/functions/prepare-layout-engine/) from `@pibbl/core`

## Complete example

[Plain source](/minimal/lifecycle/prepare-layout-engine.tsx). Run as a browser module after the document body exists. TSX uses `jsx: "react-jsx"` and `jsxImportSource: "@pibbl/core"`.

```tsx
import { Rectangle, pibbl, prepareLayoutEngine } from "@pibbl/core";

await prepareLayoutEngine();
const canvas = document.createElement("canvas");
canvas.width = 240;
canvas.height = 100;
document.body.append(canvas);
const controller = await pibbl(
  canvas,
  <Rectangle
    style={{ left: 20, top: 20, width: 200, height: 60, fill: "#087e8b" }}
  />,
);
window.addEventListener("pagehide", () => controller.dispose(), { once: true });

```

## Usage notes

- Uses the normal awaited mount after preparation.

## Documentation version

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