Skip to content

Commit 2f42736

Browse files
committed
fix(PictureThumbnail): Remove ineffective lazy loading
Setting image.loading = "lazy" after image.src starts the fetch was a no-op. The loading attribute is consulted before fetch begins, and for detached Image instances the fetch starts immediately when src is set. The attribute never actually deferred anything here. Removing it makes the code honest about what happens and prevents accidental activation if the order is ever reversed in a context where lazy would be harmful, such as the crop dialog.
1 parent 93a8023 commit 2f42736

4 files changed

Lines changed: 2 additions & 13 deletions

File tree

app/assets/builds/alchemy/alchemy_admin.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/builds/alchemy/alchemy_admin.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/javascript/alchemy_admin/components/picture_thumbnail.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export default class PictureThumbnail extends HTMLElement {
4343
if (alt) {
4444
this.image.alt = alt
4545
}
46-
this.image.loading = "lazy"
4746
}
4847

4948
start(src) {

spec/javascript/alchemy_admin/components/picture_thumbnail.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,6 @@ describe("alchemy-picture-thumbnail", () => {
152152
expect(element.image.alt).not.toBe("Test image")
153153
})
154154

155-
it("sets loading to lazy", () => {
156-
const element = renderComponent(
157-
"alchemy-picture-thumbnail",
158-
"<alchemy-picture-thumbnail></alchemy-picture-thumbnail>"
159-
)
160-
element.createImage("https://example.com/test.jpg")
161-
162-
expect(element.image.loading).toBe("lazy")
163-
})
164-
165155
it("uses default src from attribute", () => {
166156
const element = renderComponent(
167157
"alchemy-picture-thumbnail",

0 commit comments

Comments
 (0)