- Notifications
You must be signed in to change notification settings - Fork 26.8k
Description
In the jQuery section, there is this convention:
Scope jQuery object queries with find. jsPerf
But the jsPerf cited is actually a different test than the example given. The example prefers $('.sidebar').find('ul')
over $('.sidebar ul')
and even $('.sidebar > ul')
however the jsPerf test is not equivalent to the style guide example because it is essentially $(CACHED_NODE).find('ul')
which means it doesn't need to find the first element.
If you take a look at this modified jsPerf here you will see that 'select and find' actually has nearly as bad as performance as the 'find in context of' style, 90% slower than 'find on cached node'. Cascade and 'parent > child' selector are only 50% and 40% respectively.
Essentially, the citation behind this convention is not applicable.