gigaZhang / struts2-jquery

Automatically exported from code.google.com/p/struts2-jquery
0 stars 0 forks source link

Dialog initialization is slow #886

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

What steps will reproduce the problem?
1. Create a html with large number of tags
2. Use <s:dialog> in this html

What is the expected output? What do you see instead?
When loading, browser should load page instantly. Instead I see that browser is 
hanging, and in IE you may be prompted to stop long running javascript. In most 
recent browser versions this effect is not as pronounced as with older versions 
of same browsers (IE9 works fine, however IE8 and earlier very slowly).

Which struts2 version?
2.3.4.1

Which struts2-jquery plugin version?
3.3.3

Please provide any additional information below.

This is caused because of an inefficient jQuery selector in dialog 
initialization.

Instead of using this (jquery.ui.struts2-3.3.3.js line 179):
widgetInst = $(".ui-dialog:has("+self.escId(o.id)+")");

It is better to use the following variant:
widgetInst = $(".ui-dialog").has(self.escId(o.id));

The difference is that in first case it searches one by one through all tags 
(1500+ in my case). The optimized version will find first all dialogs and then 
filter dialogs by has( id ).

Original issue reported on code.google.com by octav...@ciubotaru.net on 5 Sep 2012 at 3:13

GoogleCodeExporter commented 9 years ago
Thanks for this suggestion.

Original comment by johgep on 8 Sep 2012 at 3:50

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/struts2-jquery/source/detail?r=1707

Original comment by johgep on 8 Sep 2012 at 4:06

GoogleCodeExporter commented 9 years ago
I've seen the commit and you updated source js. But minimized js is unchanged. 
Is this ok?

Original comment by octav...@ciubotaru.net on 12 Sep 2012 at 9:41

GoogleCodeExporter commented 9 years ago

Original comment by johgep on 15 Oct 2012 at 6:45