js catch all images errors

JavaScript
 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)
Source

Also in JavaScript: