CKTIS / HTML
decoding: an image-decoding preference
Separate decoding readiness from downloading, lazy loading and paint timing.
Version: HTML Living Standard
Syntax
<img decoding="async" src="/picture.svg" alt="Blue square">The image attribute decoding accepts sync, async or auto. It suggests whether decoding should be coordinated with other content’s presentation or allowed to complete separately; missing and invalid values use the automatic state. This is a hint, not a promise about a particular frame or thread.
It does not replace lazy loading, fetch priority or image dimensions. To wait explicitly for an image to be decoded before inserting it, use decode() and handle rejection when loading or decoding fails. Merely setting the attribute does not tell application code that pixels are ready.
The fixture requests a local image, awaits successful decoding and only then adds it to the document. The test checks the natural dimensions and actual insertion. It does not infer a guaranteed asynchronous paint schedule from the attribute value.
Examples
<!doctype html><meta charset="utf-8"><div id="mount"></div><output id="result"></output><script>
const image = new Image(); image.alt = 'Blue square'; image.decoding = 'async'; image.src = '/picture.svg';
image.decode().then(() => {
document.querySelector('#mount').append(image);
document.querySelector('#result').textContent = 'decoded=' + (image.naturalWidth === 20) + '; mounted=' + image.isConnected;
});
</script>Result
decoded=true; mounted=true
The result proves successful decoding and insertion of this image, not universal scheduling behavior.