English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML Audio/Video DOM Reference Manual
The video starts loading as soon as the page is loaded:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML Audio/Video preload attribute usage-Basic Tutorial(oldtoolbag.com)/<title> </<head> <body> <button onclick="enablePreload()" type="button">Load video</button> <button onclick="disablePreload()" type="button">Do not load video</button> <button onclick="checkPreload()" type="button">Check preload status</button> <br> <video id="video1" controls="controls"> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support HTML5 video tag. </video> <script> myVid=document.getElementById("video1"); function enablePreload() { myVid.preload="auto"; } function disablePreload() { myVid.preload="none"; } function checkPreload() { alert(myVid.preload); } </script> </body> </html>Test to see ‹/›
The preload attribute sets or returns whether audio should start loading immediately after the page is loaded/Video.
The preload attribute allows the author to provide information to the browser about/She believes that these hints will bring the best user experience. In some cases, this attribute can be ignored.
IEFirefoxOperaChromeSafari
All major browsers support the preload attribute.
Note:Internet Explorer 8 And earlier versions do not support this attribute.
Set the preload attribute:
audio|video.preload="auto|metadata|none"
Return the preload attribute:
audio|video.preload
Value | Description |
---|---|
auto | Indicate that audio should start loading as soon as the page is loaded/Video. |
metadata | Indicate that audio should be loaded after the page is loaded/Metadata of the video. |
none | Indicate that audio should not be loaded after the page is loaded/Video. |
Return value: | String value, auto|metadata|none |
---|