decodeImage
Loads an image and waits until it is decoded, so it can be painted without a flash or a decoding pause (e.g. before swapping screens).
Outside a browser (no Image), it rejects with a TypeError.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
src | string | The image URL |
Returns
Section titled “Returns”Promise<HTMLImageElement> — The decoded image element
Examples
Section titled “Examples”Swap screens without a flash
Section titled “Swap screens without a flash”Insert the image only once it is decoded.
Handle a broken image
Section titled “Handle a broken image”A missing or corrupt image rejects, so it can be replaced by a placeholder.
