Created
January 16, 2022 21:04
-
-
Save dorianmariecom/7c126099ba54d1c3b7ba00243d360712 to your computer and use it in GitHub Desktop.
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
| = javascript_tag nonce: true do | |
| ' (function() { | |
| ' const images = [...document.querySelectorAll("img")]; | |
| ' let count = 0; | |
| ' | |
| ' const ready = () => { | |
| ' const div = document.createElement("div"); | |
| ' div.id = "HCTIReadyNow"; | |
| ' document.body.appendChild(div); | |
| ' }; | |
| ' | |
| ' const onLoad = () => { | |
| ' count += 1; | |
| ' if (count >= images.length) { | |
| ' ready() | |
| ' } | |
| ' }; | |
| ' | |
| ' images.forEach((image) => { | |
| ' image.onload = onLoad; | |
| ' | |
| ' if (image.complete && image.naturalHeight !== 0) { | |
| ' count += 1; | |
| ' } | |
| ' }); | |
| ' | |
| ' if (images.length === count) { | |
| ' ready() | |
| ' } | |
| ' })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment