| Category | Event types |
|---|---|
| Loading | load, error, abort |
| Media | play, pause, timeupdate, ended ... |
| Storage | storage (fires in other same-origin tabs) |
addEventListener("error", (e) => {
const img = e.target;
if (!(img instanceof HTMLImageElement) || img.dataset.fallback) return;
img.dataset.fallback = "1"; // avoid a loop if the placeholder fails too
img.src = "/img/placeholder.svg";
}, { capture: true });Element load and error events do not bubble, so a window listener sees them only while capturing. Images already in the markup may have loaded before your script ran; check img.complete.