From 54a7ceda33821d74f6739a8d2495ffa0905dfa1b Mon Sep 17 00:00:00 2001 From: Mike Lynch Date: Sat, 11 Jan 2025 17:51:02 +1100 Subject: [PATCH] Put the wasm load in its own code block --- src/index.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/index.md b/src/index.md index d63cead..70d3203 100644 --- a/src/index.md +++ b/src/index.md @@ -21,8 +21,6 @@ import random from "npm:random"; import * as resvg from 'npm:@resvg/resvg-wasm'; -await resvg.initWasm(fetch('https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm')); - const CELL = 10; const MAG = 2; const WIDTH = 20; @@ -61,6 +59,14 @@ const randomise_all = view(Inputs.button("Random", {label:"all"})); +``` + +```js +// in its own code block so that it doesn't slow down load for the rest +// of the page +await resvg.initWasm(fetch('https://unpkg.com/@resvg/resvg-wasm/index_bg.wasm')); + +const wasm_init = "ready"; ``` @@ -164,6 +170,11 @@ display(download(() => { const thing = download_as_svg(svg.node()) return thing; }, "poptimal.svg", "Save as SVG")); +``` + +```js + +await wasm_init; display(download(() => { console.log("PNG value");