Audio preload attribute
Example
Start loading the audio as soon as the page loads:
var x = document.getElementById("myAudio").preload;
x
The output is:
none // the audio is not loaded when the page loads
Try it »
Definition and Usage
The preload attribute sets or returns whether the audio should be loaded immediately after the page loads.
The preload attribute describes whether the audio should be preloaded after the page loads.
**Note:** If the autoplay attribute is used, the preload attribute is ignored.
Note:
Browser support





All major browsers support the preload attribute.
Note: Internet Explorer does not support the preload attribute.
Syntax
Return the preload attribute:
audioObject
.preload
Set the preload attribute:
audioObject
.preload="auto|metadata|none"
Attribute values
| Value | Description |
|---|---|
| auto | Indicates that the audio starts loading once the page loads. |
| metadata | Indicates that only the metadata of the audio is loaded after the page loads. |
| none | Indicates that the audio should not be loaded after the page loads. |
Technical Details
| Return Value: | String representing the preloaded data. Possible return values are "auto", "metadata", or "none". You can see what "Attribute Values" represents. |
|---|
More examples
Example
The following example demonstrates how to set different attribute values:
document.getElementById("myAudio").preload="none";
document.getElementById("myaudio").preload="auto";
Try it »
Related pages
HTML Reference Manual: HTML
Audio object