English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML Audio/Video DOM preload attribute

 HTML Audio/Video DOM Reference Manual

Online Example

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 ‹/›

Definition and Usage

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.

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the preload attribute.

Note:Internet Explorer 8 And earlier versions do not support this attribute.

Syntax

Set the preload attribute:

audio|video.preload="auto|metadata|none"

Return the preload attribute:

audio|video.preload

Attribute value

ValueDescription
autoIndicate that audio should start loading as soon as the page is loaded/Video.
metadataIndicate that audio should be loaded after the page is loaded/Metadata of the video.
noneIndicate that audio should not be loaded after the page is loaded/Video.

Technical Details

Return value:String value, auto|metadata|none
 HTML Audio/Video DOM Reference Manual