Side navigation
#12913 closed bug (notabug)
Opened November 17, 2012 02:16AM UTC
Closed November 19, 2012 10:31PM UTC
use childElementCount or Element.children.length for $j('#test').children().length to improve performance
Reported by: | davidtwtong@gmail.com | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 2.0 |
Component: | traversing | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
http://jsperf.com/jquery-child-ele-size/10
childElementCount seems to be a lot faster. Looks like it should be used to calculate the number of children for browser that supports it? Might need a new method though... like $j('#test').childrenSize()
What do you think?
Attachments (0)
Change History (3)
Changed November 17, 2012 02:48AM UTC by comment:1
component: | unfiled → traversing |
---|---|
milestone: | None → 2.0 |
priority: | undecided → high |
Changed November 17, 2012 03:14AM UTC by comment:2
I don't see how this is useful. This is barely related to anything that exists in jQuery today and isn't something we should be adding a new API for.
Changed November 19, 2012 10:31PM UTC by comment:3
resolution: | → notabug |
---|---|
status: | new → closed |
@scott.gonzalez +1
We may be able to take advantage of childElementSize internally, but this is not a bug.
For the 1.x line, using the newer APIs that are unsupported by oldIE generally won't have a good payback. The traversal methods are rarely a bottleneck, and if we still have to support oldIE we're basically doubling the code paths and making the code larger.
jQuery 2.0 is a totally different story though. Since our short pole is IE9, we can take advantage of ES4 and later DOM methods and get rid of the old code (I hope).
Since we don't currently have a ticket for this in 2.0 we might as well use yours.
Just this week, Nicholas Zakas covered quite a few of these APIs:
http://www.nczonline.net/blog/2012/11/13/javascript-apis-youve-never-heard-of/