HTML - attributes - preload

revision:


Content

"preload" attribute : how media should be loaded syntax some examples


"preload" attribute : how media should be loaded

top

The preload attribute specifies if and how the author thinks that the media file should be loaded when the page loads. The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances The preload attribute is ignored if autoplay is present.

The preload attribute can be used on the following element: <video> and <audio>


syntax

top

<element preload="auto | metadata | none" ></element>

Attribute values:

auto is used to specify that the browser should load the entire video when the page loads;
metadata is used to specify that the browser should load only metadata when the page loads;
none is used to specify that the browser should NOT load the video when the page loads.


some examples

top

Click on the play button to play a sound:

codes:
                    <p class="spec">Click on the play button to play a sound:</p>
                    <audio style="margin-left:3vw;" controls preload="none">
                        <source src="../../pics/horse.wav" type="audio/wav">
                        Your browser does not support the audio element.
                    </audio>
                
codes:
                    <video style="margin-left:3vw;" width="320" height="240" controls 
                    preload="none">
                        <source src="../../pics/Wuzhen-20-10_02.mp4" type="video/mp4">
                        Your browser does not support the video tag.
                    </video>