unsafe_where_true
unsafe_where_true

Reputation: 6320

html video tag: does the browser download the video on page load?

If you put video tags on a page, with not much other attributes other than src (just a onclick javascript handler), what is the usual behavior of browsers? Will they download the video(s) completely? Just some frames? Is this browser specific?

I have been asked to review a site, which showcases a lot of videos, so I am just curious.

Upvotes: 2

Views: 2529

Answers (1)

Mick
Mick

Reputation: 25511

This behaviour is browser specific and as browsers get updated so often it may change over time. I believe the spec 'advises' the default to be 'metadata' (see below).

There is a 'preload' attribute which can have several values to instruct the browser to do what you want. It is a 'hint' attribute so browser do not have to follow it:

  • auto - load when the page loads
  • metadata - only load the metadata when the page loads
  • none - don't load the video when the page loads

If the attribute is present with not value or an empty string then is taken as auto case above.

Its worth being aware that this page may be ignored in some cases - one common example was browsers on mobile devices which in the past generally ignored preload to protect a users data usage, although this is changing now.

More info here - worth checking as browsers change often: https://developer.mozilla.org/en/docs/Web/HTML/Element/video

Its probably worth mentioning also that if the video server is providing the video in a streamed format such as HLS or MPEG DASH, then the client will typically only download enough of the video to fills its buffer anyway. These protocols split the video into segments or chunks which the client downloads as required.

Upvotes: 5

Related Questions