Audio preload attribute
Definition and usage
preload
Attribute sets or returns the The <audio> preload attribute Value.
The preload attribute specifies whether and how to load audio when the page is loaded.
The preload attribute allows the author to provide hints to the browser about what they believe will provide the best user experience. In some cases, this attribute may be ignored.
Note:If the autoplay attribute exists, ignore the preload attribute.
Example
Example 1
Find out whether and how to load audio when the page is loaded:
var x = document.getElementById("myAudio").preload;
Example 2
Demonstrate how to set different attribute values:
document.getElementById("myAudio").preload = "none"; document.getElementById("myaudio").preload = "auto";
Syntax
Return the preload attribute:
audioObject.preload
Set the preload attribute:
audioObject.preload = "auto|metadata|none"
Attribute value
Value | Description |
---|---|
auto | The author believes that the browser should load the entire audio when the page is loaded. |
metadata | The author believes that the browser should only load metadata when the page is loaded. |
none | The author believes that the browser should not load audio when the page is loaded. |
Technical Details
Return value: |
String value, indicating which data should be preloaded (if any). Possible return values are "auto", "metadata", or "none". |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <audio> preload Attribute