Skip to content
Product and web UIguide

How to handle a broken icon URL without an error loop

By SkeuDesign Editorial Team1 min read

Answer in brief

Handle the image error event and attempt a known fallback at most once. Keep the control's label available even if both the original and fallback resources fail.

Break both URLs deliberately

In a local fixture, point an account badge at a missing file. Switch to a default badge on the first error and guard against another swap. Remove the fallback too and verify that network requests stop and the account name remains readable.

Handle responsive candidates during fallback

If srcset still points at a broken candidate, replacing only src can leave the browser selecting that same failed file. In the error state, render a simple fallback img without the original sources. Test under the density or media condition that selected the failed asset in the first place.

Sources

  1. [1] HTMLElement: error event - Web APIs — MDN Web Docs, accessed November 23, 2026

Frequently asked questions

Can I rely on a parent catching every image error by bubbling?

The element error event does not bubble. Attach the handler to the image or use an appropriate capture strategy.