Ticket #10720 (closed bug: worksforme)
Selector performance regression when parsing XML
| Reported by: | steveworkman | Owned by: | steveworkman |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Related to http://bugs.jquery.com/ticket/10377 jQuery 1.7 no longer supports selecting XML nodes by [nodeName='z:row']. The agreed workaround is to use "z
:row, row" as the selector instead.
Running this through larger amounts of data, I'm seeing significant slow-down in IE browsers when using 1.7 compared to using 1.6.4. JSPerf test can be seen here http://jsperf.com/node-vs-double-select
Performance appears to have reduced by half in IE8, Opera 12 and Safari 5.1 and by small amounts in other browsers. Chrome and Firefox performance is almost identical.
Change History
comment:1 follow-up: ↓ 2 Changed 19 months ago by dmethvin
- Owner set to steveworkman
- Status changed from new to pending
comment:2 in reply to: ↑ 1 Changed 19 months ago by steveworkman
- Status changed from pending to new
Replying to dmethvin:
Did you try the custom plugin in the ticket? If you're having performance issues that should be much faster.
I've updated the perf test http://jsperf.com/node-vs-double-select with a custom filter-based plugin. It works and is a lot faster, but in order to select the right set in the first place I have to go 8 levels of children() down because filter does not recurse like find does. It is much faster, but:
- doesn't solve the performance problem in 1.7
- isn't work-able because I'm having to use multiple .children() calls
comment:3 follow-up: ↓ 4 Changed 19 months ago by dmethvin
- Status changed from new to pending
If you're going that deep, use a filter function passed to .find(). How does that fare?
comment:4 in reply to: ↑ 3 Changed 19 months ago by steveworkman
- Status changed from pending to new
Replying to dmethvin:
If you're going that deep, use a filter function passed to .find(). How does that fare?
Testing the following function:
$.fn.filterNode = function(name) {
return this.find('*').filter(function() {
return this.nodeName === name;
});
};
I get a very fast selector, in the order of 200x faster than .find('z\\:row, row') and about 5x faster than the .children().children().children().children().children().children().children().filterNode('z:row') function.
Full jsPerf test results are at http://jsperf.com/node-vs-double-select/3
Could this one-line plugin be integrated into the selector engine to allow for faster node selection?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Did you try the custom plugin in the ticket? If you're having performance issues that should be much faster.