The onloadeddata attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the loadeddata event fires — the media data for the current playback position has finished loading (often the first frame).
That usually means readyState reached HAVE_CURRENT_DATA (or greater) for the first time. It comes after onloadedmetadata and typically before or alongside oncanplay.
Baseline · Widely available.
Not deprecated and not experimental. The loadeddata event is stable across modern browsers since about July 2015.
Data-saver may skip it.
MDN: on some mobile/tablet browsers with data-saver enabled, loadeddata may not fire. Do not rely on it alone for critical UI.
Syntax
HTML Syntax
syntax.html
<video|audio onloadeddata="script">
script is JavaScript that runs when loadeddata fires. Equivalent JS: media.onloadeddata = handler or media.addEventListener("loadeddata", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Value / pattern
Description
Try it
script
Any JavaScript run when current-position media data has loaded
Load a sample clip. When current-frame data is ready, status updates. Use Reload to fire loadeddata again.
Media
Sample media from /video/count.mp4 or /audio/count.mp3.
Player
Waiting for loadeddata…
Code
HTML Examples
Short, copy-ready snippets. Use Try It Yourself for a live editor.
Example 1 — Inline onloadeddata on Audio
Call a function when current-position media data has loaded.
HTML
<audio controls onloadeddata="handleLoadedData()">
<source src="/audio/count.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p id="status">Waiting for loadeddata…</p>
<script>
function handleLoadedData() {
document.getElementById("status").textContent =
"loadeddata fired — current frame data is ready.";
}
</script>
Order can vary slightly by browser and network, but this sequence is the usual teaching model.
Edge Cases & Pitfalls
Most surprises come from treating “frame ready” as “can play through,” or missing the event on data-saver mobiles.
mobile
Data-saver can suppress loadeddata
Per MDN, some mobile browsers with data-saver on may never fire loadeddata. Pair with other signals or UI fallbacks.
meaning
Not the same as canplay
Current-frame data ≠ enough buffered to start smoothly. Use oncanplay / oncanplaythrough for playback readiness.
target
Listen on audio/video, not source
The event targets the media element. Nested <source> tags do not receive onloadeddata.
preload
Depends on buffering policy
With preload="none", little data may load until play — so loadeddata can be delayed.
timing
May already be past readyState 2
If you attach a listener late, check media.readyState >= 2 and run your handler immediately when needed.
Compatibility
Browser Support
onloadeddata 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
onloadeddata
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support loadeddata on audio and video. Mobile data-saver modes may skip the event.
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
onloadeddataWidely supported
Bottom line: Safe to use for media load UI. Prefer addEventListener('loadeddata') in apps; account for mobile data-saver gaps.
Remember
Key Takeaways
Role: current playback position’s media data finished loading (often first frame).
readyState: typically HAVE_CURRENT_DATA (2) or greater.
Order: after loadedmetadata; before/near canplay.
Mobile: data-saver may prevent the event — plan a fallback.
One line:onloadeddata means the current frame’s data is ready — not that the whole file can play through.
Frequently Asked Questions
It is an event-handler attribute on audio or video. When the frame at the current playback position finishes loading (often the first frame), the loadeddata event fires and the JavaScript in onloadeddata runs. That corresponds to readyState HAVE_CURRENT_DATA or greater.
The HTML audio and video elements. Put the handler on the media element itself, not on nested source tags.
loadedmetadata means duration and dimensions (or track info) are known. loadeddata means media data for the current playback position has loaded — often the first frame you can display.
loadeddata means current-frame data is available (HAVE_CURRENT_DATA). canplay means enough is buffered that playback can start (HAVE_FUTURE_DATA). canplay typically comes at or after loadeddata.
MDN notes that loadeddata may not fire on mobile or tablet devices when a data-saver setting is on in the browser.
No. The loadeddata event and onloadeddata handler are standard HTML media features and Baseline widely available since about July 2015.