Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const img = new Image();
img.src = "cat.png";
img.decode().then(() => {
// image fully decoded and can be safely rendered on the screen
const orig = document.getElementById("orig");
orig.parentElement.replaceChild(img, orig);
<!-- Suggest to the browser that the decoding can be deferred -->
<img decoding="async" src="cat.png" >
<!-- Suggest to the browser that the decoding should not be deferred -->
<img decoding="sync" src="cat.png">
<!-- Let the browser figure it out -->
<img decoding="auto" src="cat.png">
<img src="cat.png">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment