Created
July 7, 2023 00:07
-
-
Save 7415963987456321/271fc92835cacc453697fdbb31a8e9e9 to your computer and use it in GitHub Desktop.
Javascript refetch all imgs
This file contains 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
// This stuff for work that I had to do at home | |
async function reloadImg(el) { | |
var elurl = el.src | |
await fetch(elurl, { cache: 'no-store', mode: 'no-cors' }) | |
.then( | |
// Maybe append # to force cache reload | |
x => { | |
el.src = "" | |
el.src = elurl | |
} | |
) | |
}; | |
ass = document.querySelectorAll('img').forEach(el => reloadImg(el)) | |
//ass.forEach(e => console.log(e.src)) | |
// Problem: the queryselector returns full-url but page has relative-url | |
//url = "images/food-squirts/squirting-cheese-icon.png" | |
//document.querySelectorAll(`img[src*='${url}']`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment