How to prevent html5 video from loading before playing?

HtmlVideoHtml5 Video

Html Problem Overview


I have several html5 videos on one page and I've just realized that when you visit the page, all the videos start loading even though I haven't clicked play on any of them.

Is there a way to only load a video once you click play, to prevent unnecessary downloading?

Html Solutions


Solution 1 - Html

<!DOCTYPE html>
<html>
<body>

<video width="320" height="240" controls="controls" preload="none">
  <source src="movie.mp4" type="video/mp4" />
  <source src="movie.ogg" type="video/ogg" />
  Your browser does not support the video tag.
</video>

</body>
</html>

Use Preload"none"

http://diveintohtml5.info/video.html

Solution 2 - Html

You should use the preload attribute, and set its value to none.

Quote from the <video> specification

>preload = "none" or "metadata" or "auto" or "" (empty string) or empty
Represents a hint to the UA about whether optimistic downloading of the video itself or its metadata is considered worthwhile.

  • "none": Hints to the UA that the user is not expected to need the video, or that minimizing unnecessary traffic is desirable.

Solution 3 - Html

Just use <video preload="none">

And if you want to load meta data only of video then use <video preload="metadata">

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWill RyanView Question on Stackoverflow
Solution 1 - HtmlTimothy RadzikowskiView Answer on Stackoverflow
Solution 2 - HtmlGabriele PetrioliView Answer on Stackoverflow
Solution 3 - HtmlHarikrishnaView Answer on Stackoverflow