[wp-trac] [WordPress Trac] #10021: Unresponsive script errors on widgets screen

WordPress Trac wp-trac at lists.automattic.com
Fri Aug 7 17:31:44 UTC 2009


#10021: Unresponsive script errors on widgets screen
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |        Owner:  azaozz  
     Type:  defect (bug)       |       Status:  reopened
 Priority:  high               |    Milestone:  2.8.4   
Component:  JavaScript         |      Version:  2.8     
 Severity:  major              |   Resolution:          
 Keywords:  needs-patch        |  
-------------------------------+--------------------------------------------

Comment(by aaroncampbell):

 Just adding a quick note here for others like me that are a little out of
 the loop on jQuery's inner workings.

 My numbers were pretty different from the ones noted above because I had
 far fewer widgets.  However, `$( 'table:visible tbody .check-column
 :checkbox' ).click` was taking 40-45 ms for me.  I added some specificity
 `$( 'table:visible tbody .check-column input:checkbox' ).click` and it
 sped up to 10-11 ms.

 Denis then explained that '''jQuery processes selectors from right to
 left'''.  This means that in it's original form it actually gets all
 checkboxes then throws out the ones that don't have an ancestor with the
 check-column class, etc.  He offered an even more efficient alternative
 `$('table:visible').children('tbody').children('tr.check-
 column').find('input:checkbox')` which processes completely differently by
 first getting visible tables, then getting their bodies, ... and
 eventually getting the checkboxes.  This method reduced the processing
 time to 2-3 ms for me.

 That's 40-45ms -> 10-11ms -> 2-3ms, which is quite an improvement.  It
 seems like this could be applied to any jQuery selectors that have common
 elements toward the right side of the selector, especially if the left
 side of the selector reduces the total amount of nodes that need to be
 processed.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10021#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list