diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 8b5319d8ae2..2c25e621ea2 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -559,8 +559,6 @@ impl HTMLImageElement {
self.upcast::()
.fire_event(atom!("loadend"), can_gc);
}
-
- self.upcast::().dirty(NodeDamage::Other);
}
fn process_image_response_for_environment_change(
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 305f50dd122..db82b4ec0d4 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -646,8 +646,10 @@ impl Window {
Entry::Occupied(nodes) => nodes,
Entry::Vacant(_) => return,
};
- for node in nodes.get() {
- node.dirty(NodeDamage::Other);
+ if matches!(response.response, ImageResponse::Loaded(_, _)) {
+ for node in nodes.get() {
+ node.dirty(NodeDamage::Other);
+ }
}
match response.response {
ImageResponse::MetadataLoaded(_) => {},