document.addEventListener('error', (e) => {
console.log('Document error triggered!')
if (!e.target) {
return console.log('Received event without target!')
}
const errorTarget = e.target
const imageErrorSource = errorTarget instanceof HTMLImageElement
if (!imageErrorSource) return false
return true
}, true)
window.addEventListener("error", e => {
/* query selector images */
// image element on error => replace source
})