The preload attribute on an <audio> element specifies if and how the audio file is loaded after the page loads.
The preload value is ignored if the audio is set to autoplay.
A preload attribute on an <audio> player.
The preload option is none. The audio file is only loaded when the start button is clicked.
<audio controls preload="none">
<source src="/media/epic.mp3" type="audio/mpeg">
<source src="/media/epic.wav" type="audio/wav">
</audio>
The preload attribute specifies if and how the audio file is loaded after the page loads.
This attribute can specify that the audio file is loaded even if it is never used.
<audio preload="auto | metadata | none">
Value | Description |
---|---|
auto | Loads the entire audio file when the page loads. |
metadata | Only loads audio metadata when the page loads. |
none | Does not load the audio file when the page loads. |
empty string | Assigning no value is the same as the auto setting. |
Note: Each browser has its own default value for preload
.
For consistency the metadata
setting is a reasonable option.
Here is when preload support started for each browser:
Chrome
|
4.0 | Jan 2010 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
9.0 | Mar 2011 |
Opera
|
11.5 | May 2011 |
Safari
|
4.0 | Jun 2009 |