The onloadstart attribute is an event-handler attribute for <audio> and <video>. It runs JavaScript when the loadstart event fires — the browser has started to load the media resource.
It does not mean loading finished. Next steps are often onprogress, onloadedmetadata, then onloadeddata. A common beginner use is showing a “Loading…” status or spinner.
Baseline · Widely available.
Not deprecated and not experimental. The loadstart event is stable across modern browsers since about July 2015.
Syntax
HTML Syntax
syntax.html
<video|audio onloadstart="script">
script is JavaScript that runs when loadstart fires. Equivalent JS: media.onloadstart = handler or media.addEventListener("loadstart", handler).
Values
Attribute Values
The attribute value is always a script. Common patterns:
Value / pattern
Description
Try it
script
Any JavaScript run when the browser starts loading media
Reload a sample clip. Status updates when loadstart fires (loading has begun).
Media
Sample media from /video/count.mp4 or /audio/count.mp3.
Player
Waiting for loadstart…
Code
HTML Examples
Short, copy-ready snippets. Use Try It Yourself for a live editor.
Example 1 — Show “Loading…” on Audio
Update status as soon as the browser starts fetching the file.
HTML
<audio controls onloadstart="showLoading()">
<source src="/audio/count.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
<p id="status">Idle</p>
<script>
function showLoading() {
document.getElementById("status").textContent =
"loadstart — browser started loading media.";
}
</script>
Most surprises come from expecting “finished” when the event only means “started.”
meaning
Start ≠ ready to play
loadstart only means a load began. Use oncanplay (or later events) before treating media as playable.
preload
preload="none" can delay loadstart
With preload="none", the browser may wait until play before fetching — so loadstart is delayed.
repeat
May fire more than once
Changing the resource, calling load(), or a new network attempt can fire loadstart again. Keep handlers idempotent.
target
Listen on audio/video, not source
The event targets the media element. Nested <source> tags do not receive onloadstart.
errors
Failed loads still started
loadstart can fire before a failure. Pair with onerror / onabort for error UI.
Compatibility
Browser Support
onloadstart 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
onloadstart
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support loadstart 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
onloadstartWidely supported
Bottom line: Safe to use for “loading began” UI. Prefer addEventListener('loadstart') in apps.
Remember
Key Takeaways
Role: browser started loading the media resource.
Not finished: duration and frames come in later events.
Order: often first — then progress, loadedmetadata, …
UI tip: great place to show a loading status; hide it on later ready events.
One line:onloadstart means “fetch began” — pair it with later media events for “ready.”
Frequently Asked Questions
It is an event-handler attribute on audio or video. When the browser starts loading the media resource, the loadstart event fires and the JavaScript in onloadstart runs.
The HTML audio and video elements. Put the handler on the media element itself, not on nested source tags.
No. It only means loading has begun. Duration comes later with loadedmetadata; current-frame data with loadeddata; progress reports ongoing download.
It is typically one of the first events in the media load sequence — before progress, loadedmetadata, loadeddata, and canplay.
Often not until the user presses play (or you call load()/play()), because the browser may delay fetching. Timing depends on preload and the browser.
No. The loadstart event and onloadstart handler are standard HTML media features and Baseline widely available since about July 2015.