Open scottjehl opened 1 month ago
Huge fan of this, as it becomes more standard like img
.
Had this convo via Slack with @tunetheweb and others.
Seems like logic could make multiple things happen as you describe:
preload="none" loading="lazy" poster="/image.jpg"
would do nothing until the user scrolls near, then would load the poster and begin downloading the video; without autoplay
the user would need to initiate playing.preload="none" loading="lazy" autoplay poster="/image.jpg"
would do nothing until the user scrolls near, then would load the poster and begin downloading the video; once the video is downloaded, begin playing.preload="metadata" loading="lazy" autoplay poster="/image.jpg"
would only download metadata nothing until the user scrolls near, then would load the poster and begin downloading the video; once the video is downloaded, begin playing.It bugs me that JS is required to autoplay lazy loaded videos... :-/
What is the issue with the HTML Standard?
If the
video
element offered loading="lazy" support, that attribute could be used to determine how other desirable video features behave, such as when autoplay starts playing, and when its poster image and video file data are fetched.For example, loading=lazy combined with the autoplay attribute could cause a video to delay its poster image loading, its data fetching (other than metadata perhaps?), and its
autoplay
behavior until the video element is in (near) the viewport. Per my understanding, lazy autoplay is currently doable with JavaScript and it'd be great to offer a declarative HTML alternative.Could
<video loading="lazy" ..></video>
be one already-familiar way to offer a set of lazy behaviors for video?