Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.3.2
-
None
-
Firefox 2
Description
I'm experiencing bad performance when opening a ModalWindow. Profiling it with Firebug I found that the hot spot is modal.js -> disableFocus() -> disableFocusElement() (which is recursive and iterates over all children of <body>).
I have a (relatively) complex page with a modal window and Firebug profiler shows these results:
disableFocusElement 9823 81.72% 1379.189ms 1379.189ms 0.14ms 0.014ms 768.042ms modal.js (line 1373)
bind 9 2.9% 48.908ms 49.861ms 5.54ms 0.098ms 45.192ms modal.js (line 408)
....
As you see there are ~10000 calls to disableFocusElement (i.e. there are ~10000 sub-elements of <body>).
The following patch improves the performance and still remains the functionality:
Index: src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js
===================================================================
— src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js (revision 646196)
+++ src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js (working copy)
@@ -1251,9 +1251,9 @@
this.document = doc;
// disable user interaction
- this.hideSelectBoxes();
- this.disableTabs();
- this.disableFocus();
+ setTimeout(function() {this.hideSelectBoxes()}.bind(this), 300);
{this.disableTabs()}
+ setTimeout(function().bind(this), 400);
{this.disableFocus()}.bind(this), 1000);
+ setTimeout(function()
},
Note: calling "setTimeout(function() {this.disableFocus()}.bind(this), 500);" didn't help in my case. It needs to be bigger.
The user experience is good and I don't see any drawbacks of this modification.