The onemptied attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the emptied event fires — the media has become empty.
MDN’s classic case: media was already loaded (or partially loaded), then you call media.load() to reload it. Use it to reset UI (status text, progress, posters) before a new fetch starts with onloadstart.
Baseline · Widely available.
Not deprecated and not experimental. Per MDN, emptied is not cancelable and does not bubble. Stable since about July 2015.
Discouraged as inline HTML.
MDN discourages HTML event handler attributes. Prefer media.addEventListener("emptied", handler) in production; use inline onemptied for quick demos and learning.
Syntax
HTML Syntax
syntax.html
<video|audio onemptied="script">
script is JavaScript that runs when media becomes empty. Equivalent JS: media.onemptied = handler or media.addEventListener("emptied", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Reset UI on emptied — start “loading…” UI on loadstart.
Not the same as abort — onabort is for a fetch that was aborted.
Edge Cases & Pitfalls
Most confusion comes from expecting emptied on first load or from missing load().
trigger
Often needs a reload
MDN’s example is calling load() after media was already (partially) loaded. First paint alone may not fire emptied.
api
Not cancelable
You cannot stop the empty reset with preventDefault(). React in the handler; do not try to cancel it.
order
emptied ≠ loadstart
Reset first (emptied), then the new fetch may start (loadstart). Put “clear UI” in emptied and “loading…” in loadstart.
target
Listen on audio/video, not source
The event targets the media element. Nested <source> tags do not receive onemptied.
src
Changing src alone may not be enough
After updating a nested <source>, call media.load() so the browser restarts resource selection.
Compatibility
Browser Support
onemptied is an HTML event-handler attribute for media elements in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onemptied
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support emptied on audio and video.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet Explorer9+
Supported
onemptiedWidely supported
Bottom line: Safe to use for reset/reload UI. Prefer addEventListener('emptied') in apps, and pair with loadstart for loading feedback.
Remember
Key Takeaways
Role: media became empty — often after load() on loaded media.
Not cancelable and does not bubble.
Order: emptied (reset) → often loadstart (new fetch).
UI tip: clear progress/status on emptied; show loading on loadstart.
One line:onemptied means the media element was emptied — classic trigger is load() on already-loaded media.
Frequently Asked Questions
It is an event-handler attribute on audio or video. When the media has become empty, the emptied event fires and the JavaScript in onemptied runs — for example after calling load() to reload already-loaded media.
The HTML audio and video elements. Put the handler on the media element itself, not on nested source tags.
When media becomes empty. A common case from MDN: media was already loaded (or partially loaded), then load() is called to reload it. Changing src and calling load() can also reset the element.
No. Per MDN, emptied is not cancelable and does not bubble. You cannot stop the reset with preventDefault().
emptied means the element was cleared / became empty. loadstart means the browser begins looking for media data for a new load. On a reload you often see emptied, then loadstart.
No. The emptied event and onemptied handler are standard HTML media features and Baseline widely available since about July 2015.