whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.85k stars 2.57k forks source link

Video loading=lazy attribute support #10376

Open scottjehl opened 1 month ago

scottjehl commented 1 month ago

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?

aarontgrogg commented 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:

It bugs me that JS is required to autoplay lazy loaded videos... :-/