Attempts to load an image via fetch and sets it as a data URL on the given element.
This approach allows you to:
⚠️ Trade-offs:
When to use:
For most cases, prefer using the element's onerror handler for better performance and simplicity.
The target element.
The preferred image source URL.
What to do when loading the preferred source fails. Can be either a function (called with (img, error)) or a different image source URL.
Attempts to load an image via fetch and sets it as a data URL on the given
element.
This approach allows you to:
⚠️ Trade-offs:
When to use:
For most cases, prefer using the
element's onerror handler for better performance and simplicity.