Computer >> Computer tutorials >  >> Programming >> Javascript

How to prevent the HTML5 video from loading before playing?


To prevent HTML5 video from loading before playing, you can try to run the following code. You need to use preload attribute and set it to none −

<!DOCTYPE html>
<html>
   <body>
      <video width = "350" height = "200" 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>