Skip to content

Add loading prop to html.Img and html.Iframe - #4238

Open
toyeshhm wants to merge 1 commit into
plotly:nextfrom
toyeshhm:fix-2423-img-loading
Open

toyeshhm wants to merge 1 commit into
plotly:nextfrom
toyeshhm:fix-2423-img-loading

Conversation

@toyeshhm

@toyeshhm toyeshhm commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #2423.

html.Img(src=..., loading="lazy") raises TypeError: ... received an unexpected keyword argument: loading, so there is no way to use the browser's built-in lazy loading for images or iframes.

The html components only get the attributes listed in supportedAttributes in scripts/extract-attributes.js, and loading was not in that list, so the MDN extraction dropped it. This PR adds loading to the list, as suggested in the issue, and updates scripts/data/attributes.json with the entry the extraction produces for it (img and iframe, with the MDN description). Running npm run extract against the current MDN page gives exactly this diff and nothing else.

Contributor Checklist

  • This PR targets next (new prop)
  • I have broken down my PR scope into the following TODO tasks
    • Add loading to supportedAttributes
    • Add the loading entry for img and iframe to attributes.json
    • Tests and CHANGELOG
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

test_loading_attribute in tests/test_dash_html_components.py builds html.Img(loading="lazy") and html.Iframe(loading="lazy"), and failed before the change with the TypeError above. test_loading_attribute in tests/test_integration.py renders both in a browser and checks the loading attribute on the DOM elements.

optionals

  • I have added entry in the CHANGELOG.md

Copilot AI balanced review requested due to automatic review settings December 2, 2026 22:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants