diff --git a/IPython/html/static/widgets/js/widget_box.js b/IPython/html/static/widgets/js/widget_box.js
index 7fdc20cae..a8c6fd8c6 100644
--- a/IPython/html/static/widgets/js/widget_box.js
+++ b/IPython/html/static/widgets/js/widget_box.js
@@ -79,6 +79,9 @@ define([
},
remove: function() {
+ // We remove this widget before removing the children as an optimization
+ // we want to remove the entire container from the DOM first before
+ // removing each individual child separately.
BoxView.__super__.remove.apply(this, arguments);
this.children_views.remove();
},
diff --git a/IPython/html/static/widgets/js/widget_selectioncontainer.js b/IPython/html/static/widgets/js/widget_selectioncontainer.js
index 61a517f0e..b2b2c2608 100644
--- a/IPython/html/static/widgets/js/widget_selectioncontainer.js
+++ b/IPython/html/static/widgets/js/widget_selectioncontainer.js
@@ -128,6 +128,9 @@ define([
},
remove: function() {
+ // We remove this widget before removing the children as an optimization
+ // we want to remove the entire container from the DOM first before
+ // removing each individual child separately.
AccordionView.__super__.remove.apply(this, arguments);
this.children_views.remove();
},
@@ -252,6 +255,9 @@ define([
},
remove: function() {
+ // We remove this widget before removing the children as an optimization
+ // we want to remove the entire container from the DOM first before
+ // removing each individual child separately.
TabView.__super__.remove.apply(this, arguments);
this.children_views.remove();
},