Edit: bolded the reason this isn't a duplicate. It was already three words from the start, it was already repeated for emphasis.
Given an HTMLImageElement that's already loaded (load or error event already fired), does anybody know of a good way to tell if the load failed?
Strategies I've come up with:
img.src = img.src
then catch the load or error event. Browsers seem to optimize this away and not actually make a network request, but I'd be much more comfortable with a solution that doesn't assume optimizations.- Change the alt text then see if the size changed. Very tough to make this robustly interoperate with the page's CSS and external event listeners on the image.
Edit: bolded the reason this isn't a duplicate, because apparently putting it in the first sentence and wording it two different ways still didn't get anybody to pay attention.