Skip to content

Lazy-loading media elements fire loadstart and reject source candidates before deferring, unlike Chrome #12973

Open

Description

@zcorpan

The resource selection algorithm's synchronous section runs regardless of the lazy loading attribute:

⌛ Set the media element's networkState to NETWORK_LOADING.

⌛ Queue a media element task given the media element to fire an event named loadstart at the media element.

...and in children mode, source candidates are checked and rejected there too:

⌛ If candidate has a type attribute whose value, when parsed as a MIME type (including any codecs described by the codecs parameter, for types that define that parameter), represents a type that the user agent knows it cannot render, then end the synchronous section, and jump down to the failed with elements step below.

Only the resource fetch algorithm parks:

If the will lazy load element steps given the media element return true: … Return.

So for a below-viewport loading=lazy video, the spec has networkState at NETWORK_LOADING, loadstart fired, and error fired at any source with an unsupported type, all before the element is ever scrolled into view.

In Chrome Canary, none of that appears to happen while the video is below the viewport: networkState is NETWORK_IDLE by the time the load event fires, and no loadstart or source error events fire. Once the video is scrolled into view, loadstart and the source error fire and the load proceeds. The existing wpt tests video-loading-lazy-to-eager.html and video-loading-lazy-not-rendered.html assert that loadstart doesn't fire while lazy, matching Chrome rather than the spec.

Maybe the lazy check should be earlier in the resource selection algorithm, with the resumption steps covering candidate selection too?

(Found while writing a test for #12971.)

Activity

  1. added
    topic: media
    on Sep 21, 2026
  2. zcorpan commented on Sep 21, 2026

    @zcorpan
    MemberAuthor
  3. deleted a comment from on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: media

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions