diff --git a/src/embed-images.ts b/src/embed-images.ts index 0d7b51ad..94f49d0b 100644 --- a/src/embed-images.ts +++ b/src/embed-images.ts @@ -67,7 +67,12 @@ async function embedImageNode( const image = clonedNode as HTMLImageElement if (image.decode) { - image.decode = resolve as any + image.onload = () => { + image.decode().finally(() => { + requestAnimationFrame(resolve) + }) + } + image.decoding = 'sync' } if (image.loading === 'lazy') { diff --git a/src/util.ts b/src/util.ts index 3d430c8f..1bd37304 100644 --- a/src/util.ts +++ b/src/util.ts @@ -200,7 +200,7 @@ export function createImage(url: string): Promise { return new Promise((resolve, reject) => { const img = new Image() img.onload = () => { - img.decode().then(() => { + img.decode().finally(() => { requestAnimationFrame(() => resolve(img)) }) }