Reputation: 1476
I've been encountering some issues where HTML5 video elements will just not load, or the first second will load and then not play, or will load excruciatingly slowly. I'm still trying to debug, but right now the only question I could ask would be 'why isn't it working', which is really not a great question for SO.
But in the course of my debugging, I came across this little gem on W3Schools:
The preload attribute allows the author to provide a hint to the browser about what he/she thinks will lead to the best user experience. This attribute may be ignored in some instances.
Because W3Schools is... not that great, as we all know, they didn't bother to go into detail. This might be part of the problem, since the videos obviously aren't preloading properly. But regardless of whether this is the problem, I'm actually curious about this and can't seem to find any answers online.
The only answer I found was that the preload attribute isn't supported by some mobile browsers, and that it is ignored if the autoplay attribute is also present, but if it was that simple, I have to imagine they would have just said that.
So: when and why is the HTML5 video preload attribute ignored?
Upvotes: 1
Views: 2456
Reputation: 88036
The short answer is that a browser can choose to ignore preload
any time it wants to.
The longer answer is, the HTML spec gives no rules on when preload
must be ignored or when it should be ignored. In fact, the HTML spec defines preload
as literally just a hint, and due to that, the effect is that the spec places no hard requirements about it on browsers.
The preload attribute is intended to provide a hint to the user agent about what the author thinks will lead to the best user experience. The attribute may be ignored altogether, for example based on explicit user preferences or based on the available connectivity.
So the result of that is, it’s a bit of free-for-all as far as what behavior you can expect to get in browsers. One browser may choose to ignore it in some particular case, while another may not.
Upvotes: 1