-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy loading video element poster attribute #6636
Comments
cc @whatwg/media @domfarolino |
Paging some people involved in #3752: @bengreenstein @domenic @jakearchibald @zcorpan If we just add a |
Gut feeling: Otherwise, combinations like |
I wonder if it makes more sense to bring all of <video use-first-child-img-or-picture-as-poster-also-rename-this-attribute>
<source ...>
<picture>
<source ...>
<img loading="lazy" decode="async" srcset="..." sizes="...">
</picture>
</video> Otherwise how do we add |
If |
I like that!
|
It's not so weird if it also applies to |
I think these are the options to solve this issue:
For lazy-loading of the video:
|
I'm not sure it's worthwhile to specify lazy-loading for video, since |
@zcorpan would
mean that mean authors would be able to provide alternative text for the poster then? because that'd be something people have wanted for quite some time, and would be most welcome. |
@scottaohara maybe, but I think it's better to discuss alt text (or accessible name) for For now, |
We're talking about different things, @zcorpan. Those attributes can be used to provide a name for the 'video' element, but they would not (and should not) be used to provide a description for the poster itself. This graphic is often used (misused) to provide some sort of title card with content that is only available via that image, and is only relevant when that image is displayed, has long been a frustrating topic for some. Here is a closed HTML AAM issue which then links to other past issues on the subject. (following the links leads to some pretty heated 'discussion') Understood if you think this should be spun out into a separate issue, but the reason I brought it up is because of your mention of "all of img's features", and if this idea is accepted, then this image (and thus its alternative text) could be exposed. |
Here's what I'm reading from the various conversations above, also with my preference. <video
src="url_of_src" // URL of video source
poster="url_of_img" // URL of image source
aria-label="Video element name" // Describes the name of the video element, similar to describing a button label
alt="Description of video content" // Describes the contents of the video itself, similar to image alt text
loading="lazy" // Lazy load the video element and poster image
preload="none" // Don't preload the video element, similar to loading="lazy", but could also help define how to lazy load the video
> It makes more sense for |
@scottaohara ok. Yeah, I think a separate issue would be best to align on how to expose the poster image to ATs. It might inform how we want to solve this issue, but still lazy loading and accessibility are orthogonal concerns. |
I think we should add |
Add a new posterloading attribute to the video element which controls lazy-loading of the poster image. Fixes #6636.
PR: #8428 This issue still has |
|
^^ @chrishtr for Chromium interest, as his team is likely to own the implementation work. |
Confirmed interest from Chromium. |
Add a new posterloading attribute to the video element which controls lazy-loading of the poster image. Fixes #6636.
This seems fine to me as well. In general it'd be great to have it better-defined how <video ...>
<picture slot="poster">...</picture>
</video> or pretty much anything (doesn't have to use the The shadow tree of
Where the ua-defined-controls contents are, well, UA-defined, and would include captions, the video controls, etc. I wouldn't oppose to the one-off extra attribute, but that would be perhaps a more flexible / better design over-all... Would there be appetite for such a thing? |
Thanks @emilio That would be like the second option in #6636 (comment) but without ID lookup (instead relying on It's more work, but we get more features. Curious to hear what others think. |
I wonder how this would look if the source media attribute was reintroduced later as in #6363. |
just chiming in again that the idea of using picture > img within a video would be welcome for providing alternative text for the poster image. #7954 |
How common is |
Web Almanac: https://docs.google.com/spreadsheets/d/1T5oVAVmcH3sM6R-WwH4ksr2jFtPhuLXs3-iXXoABb3E/edit#gid=1515756004 - though Chromium use counter V8HTMLVideoElement_Poster_AttributeGetter is at 2.1123% and V8HTMLVideoElement_Poster_AttributeSetter at 2.0306%, but I assume this doesn't count use in HTML without author JS accessing the getter/setter, and if so, usage is probably higher. A quick query in httparchive sample_data (10,000 pages) gives 445 pages = 4.45% of pages, and 1743 pages use queries
445
1743 |
Incidentally I was looking at a similar query and the results are similar to what you have in the sample data. Uses the same data set as the Web Almanac 2022, (June 2022) sampled at 10%.
Query#standardSQL
CREATE TEMPORARY FUNCTION getAttributes(payload STRING)
RETURNS STRUCT<poster INT64> LANGUAGE js AS '''
try {
var almanac = JSON.parse(payload);
var obj = {
poster: 0,
};
for (var node of almanac.videos.nodes) {
if (typeof node.poster != "undefined") {
obj.poster++;
}
}
return obj;
} catch (e) {
return {};
}
''';
SELECT
client,
COUNTIF(total_video > 0) AS pages_with_videos,
COUNTIF(attributes.poster > 0) AS pages_with_poster,
COUNTIF(attributes.poster > 0) / COUNTIF(total_video > 0) AS pct_pages_with_poster,
COUNT(0) AS total_pages
FROM (
SELECT
_TABLE_SUFFIX AS client,
SAFE_CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.videos.total') AS INT64) AS total_video,
getAttributes(JSON_EXTRACT_SCALAR(payload, '$._almanac')) AS attributes,
FROM
`httparchive.pages.2022_06_01_*` TABLESAMPLE SYSTEM(10 PERCENT)
)
GROUP BY
client |
I discussed with @chrishtr, he said supporting @emilio wrote <video ...>
<picture slot="poster">...</picture>
</video>
Yeah, I think we shouldn't use <video posterchild>
<img ...>
<source ...>
</video> (Please suggest other names for |
Does |
Given the resent reintroduction of the |
@annevk it might change behavior for legacy web content that already use |
Why not a new Non-video supporting browsers would ignore it. Video-supporting browsers without specific support for it would ignore it as well. |
But it would only do something when it's a child of a |
Sure. Much like adding a |
( |
I don't worry about what happens in non-video supporting UAs, most likely most of the web doesn't work in those browsers for other reasons anyway. I'm more concerned about currently existing web content and the effect for such content in new browsers. However, I haven't looked into how common it is to have an |
Art direction [out-of-the-box] would be a big plus when supporting prefers-reduced-motion. |
I like the sound of Edit: I suppose a child That said, if |
This approach for lazy loading videos is close to perfect.
In a video gallery with many videos, using
preload="none"
can help speed up page loading with its lazy loading capability. The one missing feature is lazy loading the poster attribute image.I realize
loading="lazy"
only works foriframe
andimg
elements, but this one enhancement to the lazy loading capabilities would potentially be a noticeable performance improvement in addition to not preloading the videos.The text was updated successfully, but these errors were encountered: