HTML5 Video Preload
At last week’s HTML5 Developer Conference I attended Philippe Le Hegaret‘s session on ”Video in the Open Web Platform”. Since the amount of video on the Web is growing (more details in a future post), I wondered if the VIDEO tag’s preload behavior could account for that. Maybe its default behavior is to preload aggressively.
The VIDEO PRELOAD attribute has the following possible states:
- no preload attribute
- Preload is not specified.
- From the spec, “Hints to the UA that the user is not expected to need the video, or that minimizing unnecessary traffic is desirable.”
- “Hints to the UA that the user is not expected to need the video, but that fetching its metadata (dimensions, first frame, track list, duration, and so on) is desirable.”
- “Hints to the UA that optimistically downloading the entire video is considered desirable.”
- The preload attribute is specified but no value is given. Specifying the empty string is the same as specifying “auto”.
In order to gather results across various browsers I connected the test page to a Browserscope user test and tweeted asking people to run the test page. (There were some race conditions in the test page that I resolved after an awesome realtime, tweet-driven debug session with voluntary testers. It was very cool.) A subset of major browsers is shown in Table 1. You can see the full results in Browserscope.
|Table 1. Seconds of Video Preloaded|
|browser||no preload attr||
|Android 4||0 s||0 s||0 s||0 s||0 s||0 s|
|Chrome 26||25 s||0 s||25 s||25 s||25 s||52 s|
|Firefox 19||0 s||0 s||0 s||53 s||53 s||53 s|
|IE 9||2 s||0 s||2 s||52 s||52 s||52 s|
|IE 10||0 s||0 s||0 s||52 s||52 s||52 s|
|iPhone iOS6||0 s||0 s||0 s||0 s||0 s||0 s|
|Opera 12||10 s||0 s||10 s||53 s||53 s||53 s|
|Safari 6||52 s||0 s||0 s||52 s||52 s||52 s|
Observation #1: Mobile devices don’t preload anything. The VIDEO spec calls the preload values “hints”, so it makes sense that mobile browsers would choose not to preload anything in order to save on data costs. Instead, the video doesn’t start downloading until the user initiates playback. When I saw this I decided to add a test for the AUTOPLAY attribute. As shown, that also does not cause any video download on mobile devices.
Observation #2: The amount of video preloaded varies across the major desktop browsers. Luckily,
preload='none' has consistent behavior across all browsers: nothing is buffered. But all other values of PRELOAD vary in how much video data is downloaded. Chrome is aggressive about preloading, going so far as to buffer 25 seconds of video for
preload='metadata'. However, it is less aggressive for
preload='auto', stopping at 25 seconds while the other desktop browsers download the entire 52 seconds. Firefox 19 and IE 10 are generally less aggressive, buffering zero seconds for three of five preload states.
Observation #3: Browsers preload too much by default. Developers are most likely not going to specify any value for PRELOAD. As shown in Table 1, this situation results in IE 9 buffering 2 seconds of video, Opera 12 buffers 10 seconds, Chrome 26 buffers 25 seconds, and Safari 6 buffers the entire 52 seconds. The entire video is 4.2MB, so the amount of data downloaded is 0.2MB for IE9, 0.8MB for Opera 12, 2.0MB for Chrome 26, and the entire 4.2MB for Safari 6.
Looking at the Top 1000 URLs worldwide, only a handful use the VIDEO tag. Most sites are still using the Flash player, which has its own preloading behavior. But as use of the VIDEO tag increases, it would be good to determine how much video should be buffered for various values of preload, especially for the default case of no PRELOAD attribute. I suggest guidance be given to drive that to a lower number, possibly 5 to 10 seconds. If a developer wants to have the video preload, specifying PRELOAD is just an attribute away.