decode method

JSPromise<JSAny?> decode()

The decode() method of the HTMLImageElement interface returns a Promise that resolves once the image is decoded and it is safe to append it to the DOM.

This can be used to initiate loading of the image prior to attaching it to an element in the DOM (or adding it to the DOM as a new element), so that the image can be rendered immediately upon being added to the DOM. This, in turn, prevents the rendering of the next frame after adding the image to the DOM from causing a delay while the image loads.

Implementation

external JSPromise<JSAny?> decode();