Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Added
- [#4203](https://github.com/plotly/dash/pull/4203) Add a Copy button to each error in the debug toolbar, which copies the error message and its traceback to the clipboard. Closes [#3624](https://github.com/plotly/dash/issues/3624).
- [#4204](https://github.com/plotly/dash/pull/4204) Add `DASH_HOST` and `DASH_PORT` environment variables to set the listen address for `Dash.run`, taking precedence over the generic `HOST` and `PORT` variables. Fixes [#3400](https://github.com/plotly/dash/issues/3400).
- Add the `loading` prop to `html.Img` and `html.Iframe`, so `loading="lazy"` turns on the browser's lazy loading. Fixes [#2423](https://github.com/plotly/dash/issues/2423).

### Changed
- [#4118](https://github.com/plotly/dash/pull/4118) The JupyterLab extension now ships prebuilt, so JupyterLab 3 and 4 load it without asking for a rebuild. JupyterLab 2 is no longer supported. Fixes [#3828](https://github.com/plotly/dash/issues/3828).
Expand Down
9 changes: 9 additions & 0 deletions components/dash-html-components/scripts/data/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@
],
"description": "Defines the language used in the element."
},
"loading": {
"elements": [
"img",
"iframe"
],
"description": "Indicates if the element should be loaded lazily (loading=\"lazy\") or loaded immediately (loading=\"eager\")."
},
"list": {
"elements": [
"input"
Expand Down Expand Up @@ -856,6 +863,7 @@
"iframe": [
"allow",
"height",
"loading",
"name",
"referrerPolicy",
"sandbox",
Expand All @@ -878,6 +886,7 @@
"alt",
"crossOrigin",
"height",
"loading",
"referrerPolicy",
"sizes",
"src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const supportedAttributes = ['accept', 'accessKey', 'action', 'allow',
'encType', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate',
'formTarget', 'frameBorder', 'headers', 'height', 'hidden', 'high', 'href',
'hrefLang', 'icon', 'id', 'inputMode', 'integrity', 'is',
'keyParams', 'keyType', 'kind', 'label', 'lang', 'list', 'loop', 'low',
'keyParams', 'keyType', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low',
'manifest', 'marginHeight', 'marginWidth', 'max', 'maxLength', 'media',
'mediaGroup', 'method', 'min', 'minLength', 'multiple', 'muted', 'name',
'noValidate', 'nonce', 'open', 'optimum', 'pattern', 'placeholder', 'playsInline', 'poster',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ def test_customDocs():
assert "CAUTION" in html.Script.__doc__[:100]
assert "OBSOLETE" in html.Blink.__doc__[:100]
assert "DEPRECATED" in html.Marquee.__doc__[:100]


def test_loading_attribute():
assert repr(html.Img(loading="lazy")) == "Img(loading='lazy')"
assert repr(html.Iframe(loading="lazy")) == "Iframe(loading='lazy')"
16 changes: 16 additions & 0 deletions components/dash-html-components/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,19 @@ def update(n2, n3, n4):
dash_duo.wait_for_text_to_equal("#div-output", "1, 0, 1")

assert not dash_duo.get_logs()


def test_loading_attribute(dash_duo):
app = Dash(__name__)
app.layout = html.Div(
[
html.Img(id="img", loading="lazy"),
html.Iframe(id="iframe", loading="eager"),
]
)

dash_duo.start_server(app)

assert dash_duo.find_element("#img").get_attribute("loading") == "lazy"
assert dash_duo.find_element("#iframe").get_attribute("loading") == "eager"
assert not dash_duo.get_logs()
Loading