html.elements.iframe.loading - add subfeatures for lazy loading srcdoc, data: and blob: iframes

Open Beginner friendly
#30,950 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
html, json

Research direction

Start by reading the existing html.elements.iframe.loading entry and nearby browser compatibility data conventions in the repository. Add three subfeatures for srcdoc, data: and blob: iframe loading using the browser results in the issue; verify the entries match the stated support matrix. The issue notes that Firefox and Safari version numbers are unverified, so resolve those from repository or browser data before recording them.

Written by the indexing model from the issue text.

Description

data:html needs triage
What type of issue is this?

Missing compatibility data

What information was incorrect, unhelpful, or incomplete?

html.elements.iframe.loading lists Chrome 77 as fully supporting loading="lazy", with no notes. However, Chromium does not lazy-load iframes whose URL is local (about:srcdoc, data:, blob:). A below-viewport <iframe loading="lazy"> with srcdoc, a data: URL, or a blob: URL loads immediately, delays the parent's load event, and ignores the attribute entirely.

This is because Chromium only considers http(s) URLs eligible for lazy loading (IsFrameLazyLoadable() in html_frame_owner_element.cc):

// Only http:// or https:// URLs are eligible for lazy loading, excluding
// URLs like invalid or empty URLs, "about:blank", local file URLs, etc.
// that it doesn't make sense to lazily load.
if (!url.ProtocolIsInHttpFamily()) {
  return false;
}

The spec has no such restriction. Process the iframe attributes runs the will lazy load element steps for both the srcdoc branch and the URL branch, regardless of scheme. Including srcdoc was deliberate, since a local document's subresources would otherwise block the parent's load event (whatwg/html#5579).

What browsers does this problem apply to, if applicable?

Chromium (Chrome, Edge 79+, Opera, Samsung Browser), Safari

What did you expect to see?

Three subfeatures of html.elements.iframe.loading, one per kind of local URL, since support differs between them:

Subfeature Description Chromium Firefox Safari
loading.srcdoc Lazy loading of srcdoc iframes No Yes Yes
loading.data Lazy loading of data: URL iframes No Yes Yes
loading.blob Lazy loading of blob: URL iframes No Yes No

I haven't verified Firefox and Safari's version_added. Since the spec covered these cases before either shipped iframe lazy loading, it is likely the same as the parent feature (Firefox 121, Safari 16.4).

Did you test this? If so, how?

Yes, in two ways.

  1. Manually in Chrome stable: a page with two below-viewport loading="lazy" iframes, one with srcdoc and one with a same-origin src. The srcdoc iframe fired load at page load with scrollY 0. The src iframe made no request and did not fire load until scrolled into view.
  2. WPT results from the latest stable runs on wpt.fyi:
Subtest Chrome 156 Firefox 158 Safari 27
iframe-loading-lazy.html: Below-viewport srcdoc iframes load lazily FAIL PASS PASS
iframe-loading-lazy.html: Below-viewport data: url iframes load lazily FAIL PASS PASS
iframe-loading-lazy.html: Below-viewport blob url iframes load lazily FAIL PASS FAIL
iframe-loading-lazy-to-eager-srcdoc.html FAIL PASS PASS

Chromium's checked-in baselines for these tests also record them as failing.

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
Dominant language
JSON
Stars
5.8k
Forks
2.7k
Avg merge
2d 20h
Merged PRs (30d)
160

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mdn/browser-compat-data

All issues in mdn/browser-compat-data

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.