Why this is tricky

An <img> tag exists in the DOM whether or not its image actually loaded โ€” document.querySelector finding it proves nothing. The real check is img.complete && img.naturalWidth > 0, or listening for the element's error event.

Valid image

Valid

Broken path (404)

Broken

Empty src

Empty
Initial state.