diff --git a/common/renderPNG.tsx b/common/renderPNG.tsx index cdf8fab1..0ce6adf5 100644 --- a/common/renderPNG.tsx +++ b/common/renderPNG.tsx @@ -5,10 +5,18 @@ import resvgWasm from '../public/resvg_bg.wasm?module' import renderCardSVG from './renderSVG' import QueryType from './types/queryType' -const initResvgWasm = resvg.initWasm(resvgWasm) +let resvgInitialized = false const renderCardPNG = async (query: QueryType) => { - const [svg] = await Promise.all([renderCardSVG(query), initResvgWasm]) + + async function initResvg() { + if (!resvgInitialized) { + await resvg.initWasm(resvgWasm) + resvgInitialized = true + } + } + + const [svg] = await Promise.all([renderCardSVG(query), initResvg()]) const resvgJS = new resvg.Resvg(svg, { fitTo: {