Last active
June 13, 2019 12:44
-
-
Save inian/8d888f9d278444d62f40dee90bfdd0a0 to your computer and use it in GitHub Desktop.
Image decoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div class="jank-detector"> | |
Random numbers, to highlight jank: | |
<span class="rand"></span> | |
</div> | |
<script> | |
const rand = document.querySelector(".rand"); | |
function randFrame() { | |
rand.textContent = Math.random(); | |
requestAnimationFrame(randFrame); | |
} | |
randFrame(); | |
</script> | |
<script> | |
function onload1() { | |
setTimeout(() => { | |
const img = new Image(); | |
img.width = 1400; | |
img.decoding = "async"; | |
img.src = `https://res.cloudinary.com/demo/image/upload/f_auto,w_6400/q_1/string_1.jpg?${Date.now()}`; | |
img.onload = () => { | |
const orig = document.getElementById("orig"); | |
orig.parentElement.replaceChild(img, orig); | |
}; | |
}, 3000); | |
} | |
</script> | |
<div id="sdf"></div> | |
<img | |
id="orig" | |
width="1400" | |
onload="onload1()" | |
src="https://res.cloudinary.com/demo/image/upload/e_blur:1000,w_6400/q_1/string_1.jpg" | |
/> | |
<br /> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<div class="jank-detector"> | |
Random numbers, to highlight jank: | |
<span class="rand"></span> | |
</div> | |
<script> | |
const rand = document.querySelector(".rand"); | |
function randFrame() { | |
rand.textContent = Math.random(); | |
requestAnimationFrame(randFrame); | |
} | |
randFrame(); | |
</script> | |
<script> | |
function onload1() { | |
setTimeout(() => { | |
console.log("start"); | |
const img = new Image(); | |
img.width = 1400; | |
img.decoding = "sync"; | |
img.src = `https://res.cloudinary.com/demo/image/upload/f_auto,w_6400/q_1/string_1.jpg?${Date.now()}`; | |
img.onload = () => { | |
const orig = document.getElementById("orig"); | |
orig.parentElement.replaceChild(img, orig); | |
}; | |
} | |
</script> | |
<div id="sdf"></div> | |
<img | |
id="orig" | |
width="1400" | |
onload="onload1()" | |
src="https://res.cloudinary.com/demo/image/upload/e_blur:1000,w_6400/q_1/string_1.jpg" | |
/> | |
<br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment