Download image-loading.js from TuneJury/landing: direct link, hf CLI and curl.
- Browser
- Download file 917 Bytes
-
https://huggingface.co/spaces/TuneJury/landing/resolve/main/image-loading.js
- Command line
-
hf download hf://spaces/TuneJury/landing/image-loading.js
-
curl -L -o image-loading.js https://huggingface.co/spaces/TuneJury/landing/resolve/main/image-loading.js
917 Bytes
| ; | |
| // A transient image request failure must not require reloading the whole page. | |
| // Keep retries finite, including failures that happened before this deferred script ran. | |
| document.querySelectorAll('img[src^="assets/"]').forEach(img => { | |
| const original = new URL(img.getAttribute('src'), document.baseURI); | |
| let attempts = 0; | |
| let pending = false; | |
| function recover() { | |
| if (pending || attempts >= 2 || !img.complete || img.naturalWidth > 0) return; | |
| pending = true; | |
| const attempt = ++attempts; | |
| setTimeout(() => { | |
| pending = false; | |
| if (!img.isConnected || !img.complete || img.naturalWidth > 0) return; | |
| const retry = new URL(original.href); | |
| retry.searchParams.set('tj_image_retry', String(attempt)); | |
| img.src = retry.href; | |
| }, attempt * 750); | |
| } | |
| img.addEventListener('error', recover); | |
| window.addEventListener('pageshow', recover); | |
| recover(); | |
| }); | |