[wp-trac] [WordPress Trac] #15650: Inefficient selectors in common.dev.js

WordPress Trac wp-trac at lists.automattic.com
Sun Dec 5 19:05:10 UTC 2010


#15650: Inefficient selectors in common.dev.js
--------------------------+-------------------------------------------------
 Reporter:  GamajoTech    |       Owner:                         
     Type:  defect (bug)  |      Status:  new                    
 Priority:  normal        |   Milestone:  Awaiting Review        
Component:  Performance   |     Version:                         
 Severity:  minor         |    Keywords:  has-patch needs-testing
--------------------------+-------------------------------------------------

Comment(by azaozz):

 These two do the same thing:
 {{{
 $('.wp-menu-toggle', menu)...
 }}}

 {{{
 menu.find('.wp-menu-toggle')...
 }}}

 They limit the search for the `.wp-menu-toggle` class only to children of
 `menu`. Did some testing few months ago and the first one was slightly
 faster.

 It can also be written as:
 {{{
 $('li.wp-has-submenu', '#adminmenu')...
 }}}
 i.e. find `li` nodes that have `wp-has-submenu` class but search only in
 the node with id = `adminmenu`.

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


More information about the wp-trac mailing list