Re: [jQuery] More DOM Query Speed Tests
Hi, ID should be uniqe over the page, so div#myid is redundant. No, it isn't. It should return an empty jQuery-Object in case the Element with the id myid is not a div. That is usefull when you produce your Content dynamically (e.g. with PHP). The same is true for .myclass#myid, or even div.myclass#myid which should return the element with the id myid only if it is a div and has the class myclass: if( $(div.myclass#myid).length 0 ) alert(YEAH, WE GOT IT); else if( $(#myid).length 0 ) alert(Ha, my ID is misused!!); Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
looking for an ID (which should be unique) after getting the tags is worthless. Should we re-write the case of tag#id to use elem.getElementBYId(), and then remove the element if it's not the right tag? - Brian ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
2006/12/19, Christof Donat [EMAIL PROTECTED]: Hi, ID should be uniqe over the page, so div#myid is redundant. No, it isn't. It should return an empty jQuery-Object in case the Element with the id myid is not a div. That is usefull when you produce your Content dynamically (e.g. with PHP). The same is true for .myclass#myid, or even div.myclass#myid which should return the element with the id myid only if it is a div and has the class myclass: I know that. My point is that there should not be two elements with same id on the page. At least, I'm developing like that. if( $(div.myclass#myid).length 0 ) alert(YEAH, WE GOT IT); else if( $(#myid).length 0 ) alert(Ha, my ID is misused!!); Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Dragan Krstić krdr http://krdr.ebloggy.com/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
If you want to keep performance, maybe it's better to do: if( $(#myid).is('div.myclass')) alert(YEAH, WE GOT IT); else alert(Ha, my ID is misused!!); Wow. When I started writing this reply, I thought of using tagName and className, but is() is so much more elegant. Christof Donat wrote: Hi, ID should be uniqe over the page, so div#myid is redundant. No, it isn't. It should return an empty jQuery-Object in case the Element with the id myid is not a div. That is usefull when you produce your Content dynamically (e.g. with PHP). The same is true for .myclass#myid, or even div.myclass#myid which should return the element with the id myid only if it is a div and has the class myclass: if( $(div.myclass#myid).length 0 ) alert(YEAH, WE GOT IT); else if( $(#myid).length 0 ) alert(Ha, my ID is misused!!); Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi, ID should be uniqe over the page, so div#myid is redundant. [...] I know that. My point is that there should not be two elements with same id on the page. At least, I'm developing like that. But that doesn't make the expression div#myid redundant. Of course the id should be unique, but div#myid has another meaning than #myid. That's why it isn't worthless as Jake said. It even isn't worthless measuring the difference, because div#myid needs to check if the element returned by getElementById() is a div. As Karls results show, there is a noticable difference here. As far as I can judge it, Karls results suggest, that jQuery uses getElementsByTagName() and then search the result for the id. I guess it would be faster to do it the other way round. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
On Dec 19, 2006, at 1:09 AM, Aaron Heimlich wrote: If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http:// aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: $(.dialog) does 815 function calls () $('#speech28') does 6 function calls Wow, Aaron, that is very cool. Thanks! On Dec 19, 2006, at 2:32 AM, Dragan Krstic wrote: 2006/12/19, Christof Donat [EMAIL PROTECTED]: Hi, looking for an ID (which should be unique) after getting the tags is worthless. Well, it shouldn't be. I might whant to hide an Element with the id myid only if it is an image. Then I'd try first $('img#myid').hide() and expect it to work like $('#myid').filter('img').hide(). ID should be uniqe over the page, so div#myid is redundant. Dragan, I think what Christof is getting at is this: on any given page, #myid could be uniquely assigned to a div or a paragraph or a span or an image or any other element. So, page 1 could have div id=myid/ div and page 2 could have p id=myid/p If the same script is being included on multiple pages, it might be necessary to specify that an event take place only if #myid is attached to, for example, the div. In this scenario, div#myid is not redundant. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com On Dec 19, 2006, at 1:09 AM, Aaron Heimlich wrote: If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http:// aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: $(.dialog) does 815 function calls () $('#speech28') does 6 function calls On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Thank you for that summary, Jake! And for the stat lesson. :) On Dec 18, 2006, at 11:19 PM, Ⓙⓐⓚⓔ wrote: Since the 7th click is reproducible, and has little to do with the issue, you can discard the value, with a simple note... years of stat classes! conclusions: running thru the whole dom looking for a class is slow. looking for an ID (which should be unique) after getting the tags is worthless. looking for a class after getting a subset of the dom is faster than searching the whole dom. Safari is almost always faster than ff! Just what was expected! GREAT WORK! On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Hey everyone, I have results of a few more speed tests that I ran this evening at http://test.learningjquery.com/speed-test.htm Method: I clicked 10 times on each query in Firefox 2.0 and Safari 2.0.4 (See HTML source for all code, markup, etc.) I recorded the mode (most common value) and the range of values for each, all in milliseconds. @ FF2 / Safari2 1. $('#speech28') - mode: 1 / 1 - range: 0-1 / 0-4 2. $('div#speech28') - mode: 43 / 32 - range: 42-59 / 30-35 3. $('#final-speech div.final-dialog ') - mode: 5ms / 5ms - range: 4-6 / 3-6 4. $('#final-speech .final-dialog') - mode: 6 / 5 - range: 5-8 / 3-6 5. $('div.final-dialog') - mode: 55 / 40 - range: 28-253 / 40-45 6. $('.final-dialog') - mode: 101 / 51 - range: 83-306 / 51-68 *** Note that queries 5 and 6 have huge ranges in Firefox because of the mysterious seventh click issue. Looks like these tests confirm what we've all been saying on this list about the relative speed of various selectors. This has been a fascinating exercise. I'd love to hear people's analysis, etc. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi, I think what Christof is getting at is this: [...] Yes, exactly. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi, If you want to keep performance, maybe it's better to do: if( $(#myid).is('div.myclass')) alert(YEAH, WE GOT IT); else alert(Ha, my ID is misused!!); Yes, of course. If I whant to use jQuery methods I could also use filter(): $('#myid').filter('div.myclass').addClass('hereWeGo'); But I think that it would be good if people didn't have to think about alternative constructs for performance reasons. I know it isn't always possible, but I think, the library should do its best to optimize queries. jQuery is not bad here, but there is still some room for improvements. My original point was to show, that it is not worthless, as Jake wrote, to use queries like 'div#myid'. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
OK, here is an interesting tidbit. I used the test below and and did the 7 click thing, and out of all my tests except one, the long delay happened in has() and once I got it in find(). has() is pretty simple and I wonder if this has less to do with the number of clicks versus the number of regex's we use and dispose or something like that. I love testing!!! It makes one look at what is happening and sometimes you are surprised! but the questions and introspection are always good on occasion. -Steve Aaron Heimlich wrote: If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http://aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ http://aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: $(.dialog) does 815 function calls () $('#speech28') does 6 function calls On 12/18/06, *Karl Swedberg* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thank you for that summary, Jake! And for the stat lesson. :) On Dec 18, 2006, at 11:19 PM, Ⓙⓐⓚⓔ wrote: Since the 7th click is reproducible, and has little to do with the issue, you can discard the value, with a simple note... years of stat classes! conclusions: running thru the whole dom looking for a class is slow. looking for an ID (which should be unique) after getting the tags is worthless. looking for a class after getting a subset of the dom is faster than searching the whole dom. Safari is almost always faster than ff! Just what was expected! GREAT WORK! On 12/18/06, *Karl Swedberg* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hey everyone, I have results of a few more speed tests that I ran this evening at http://test.learningjquery.com/speed-test.htm Method: I clicked 10 times on each query in Firefox 2.0 and Safari 2.0.4 (See HTML source for all code, markup, etc.) I recorded the mode (most common value) and the range of values for each, all in milliseconds. @ FF2 / Safari2 *1. $('#speech28') * - mode: 1 / 1 - range: 0-1 / 0-4 *2. $('div#speech28') * - mode: 43 / 32 - range: 42-59 / 30-35 *3. $('#final-speech div.final-dialog ') * - mode: 5ms / 5ms - range: 4-6 / 3-6 *4. $('#final-speech .final-dialog')* - mode: 6 / 5 - range: 5-8 / 3-6 *5. $('div.final-dialog')* - mode: 55 / 40 - range: 28-253 / 40-45 *6. $('.final-dialog')* - mode: 101 / 51 - range: 83-306 / 51-68 *** Note that queries 5 and 6 have huge ranges in Firefox because of the mysterious seventh click issue. Looks like these tests confirm what we've all been saying on this list about the relative speed of various selectors. This has been a fascinating exercise. I'd love to hear people's analysis, etc. --Karl ___ Karl Swedberg www.englishrules.com http://www.englishrules.com www.learningjquery.com http://www.learningjquery.com ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com mailto:discuss@jquery.com http://jquery.com/discuss/ -- Aaron Heimlich Web Developer [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] http://aheimlich.freepgs.com http://aheimlich.freepgs.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi all, With the tests I ran (http://fmarcia.info/jquery/speedtest.html [1]), the quickest way to retrieve one element is $(document.getElementById(id)), even better than $('#id')! Off course, to get even better performance, one should cache queries every time it's possible! My 2 cents, Franck. [1] caution: buttons div div strong and div div strong are very slow ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Dragan, I think what Christof is getting at is this: on any given page, #myid could be uniquely assigned to a div or a paragraph or a span or an image or any other element. So, page 1 could have div id=myid/div and page 2 could have p id=myid/p If the same script is being included on multiple pages, it might be necessary to specify that an event take place only if #myid is attached to, for example, the div. In this scenario, div#myid is not redundant. But that is bad practice. I'll never use same id for different tag in app. Ah, you never know... -- Dragan Krstić krdr http://krdr.ebloggy.com/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
btw, I just added a text input so you can run whatever query you want on the page. just type in the selector -- without $() -- and press the Test! button. In case anyone wants to try but has lost the thread, here is the URL again: http://test.learningjquery.com/speed-test.htm On Dec 19, 2006, at 11:31 AM, Dragan Krstic wrote: Dragan, I think what Christof is getting at is this: on any given page, #myid could be uniquely assigned to a div or a paragraph or a span or an image or any other element. So, page 1 could have div id=myid/div and page 2 could have p id=myid/p If the same script is being included on multiple pages, it might be necessary to specify that an event take place only if #myid is attached to, for example, the div. In this scenario, div#myid is not redundant. But that is bad practice. I'll never use same id for different tag in app. Ah, you never know... As you say, you never know. ;-) We often don't have total control over markup, and I for one would have a much harder time justifying to bosses/clients time spent making each ID refer to a single tag throughout a site than, say, fixing a page that has the same ID applied to more than one element. On Dec 19, 2006, at 11:13 AM, Stephen Woodbridge wrote: OK, here is an interesting tidbit. I used the test below and and did the 7 click thing, and out of all my tests except one, the long delay happened in has() and once I got it in find(). has() is pretty simple and I wonder if this has less to do with the number of clicks versus the number of regex's we use and dispose or something like that. very interesting, indeed. Might be worth someone looking into? I love testing!!! It makes one look at what is happening and sometimes you are surprised! but the questions and introspection are always good on occasion. Yes, well put! --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Stephen Woodbridge schrieb: OK, here is an interesting tidbit. I used the test below and and did the 7 click thing, and out of all my tests except one, the long delay happened in has() and once I got it in find(). has() is pretty simple and I wonder if this has less to do with the number of clicks versus the number of regex's we use and dispose or something like that. I love testing!!! It makes one look at what is happening and sometimes you are surprised! but the questions and introspection are always good on occasion. That is an interesting point. I wonder if it makes sense to cache regular expressions. Eg: function cache(expression, options) { var key = expression + options || ; var regex = cache[key]; if(!regex) { regex = cache[key] = new RegExp(expression, options); } return regex; } Appending the options to the cache key should prevent any ambiguity. The intersting questions: Is it more efficient to cache regular expressions then to let the garbage collected? -- Jörn Zaefferer http://bassistance.de ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Oh man, that is totally awesome. Just the kind of thing I was hoping people would do with Firebug. The jQuery community rocks! :) - Joe If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http://aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: -- View this message in context: http://www.nabble.com/More-DOM-Query-Speed-Tests-tf2843982.html#a7955115 Sent from the JQuery mailing list archive at Nabble.com. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Thanks for stopping by Joe. Firebug rocks man and we're VERY appreciative of your efforts. Thanks for making this amazing tool for us developers. Rey joehewitt wrote: Oh man, that is totally awesome. Just the kind of thing I was hoping people would do with Firebug. The jQuery community rocks! :) - Joe If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http://aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
On 12/19/06, joehewitt [EMAIL PROTECTED] wrote: Oh man, that is totally awesome. Just the kind of thing I was hoping people would do with Firebug. The jQuery community rocks! :) - Joe Thanks Joe! I know you've probably been hearing this alot lately, but Firebug (particulary 1.0 beta) really is indescribably amazing. It is an irreplaceable part of my development process. -- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Since the 7th click is reproducible, and has little to do with the issue, you can discard the value, with a simple note... years of stat classes! conclusions: running thru the whole dom looking for a class is slow. looking for an ID (which should be unique) after getting the tags is worthless. looking for a class after getting a subset of the dom is faster than searching the whole dom. Safari is almost always faster than ff! Just what was expected! GREAT WORK! On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Hey everyone, I have results of a few more speed tests that I ran this evening at http://test.learningjquery.com/speed-test.htm Method: I clicked 10 times on each query in Firefox 2.0 and Safari 2.0.4(See HTML source for all code, markup, etc.) I recorded the mode (most common value) and the range of values for each, all in milliseconds. @ FF2 / Safari2 *1. $('#speech28') * - mode: 1 / 1 - range: 0-1 / 0-4 *2. $('div#speech28') * - mode: 43 / 32 - range: 42-59 / 30-35 *3. $('#final-speech div.final-dialog')* - mode: 5ms / 5ms - range: 4-6 / 3-6 *4. $('#final-speech .final-dialog')* - mode: 6 / 5 - range: 5-8 / 3-6 *5. $('div.final-dialog')* - mode: 55 / 40 - range: 28-253 / 40-45 *6. $('.final-dialog')* - mode: 101 / 51 - range: 83-306 / 51-68 *** Note that queries 5 and 6 have huge ranges in Firefox because of the mysterious seventh click issue. Looks like these tests confirm what we've all been saying on this list about the relative speed of various selectors. This has been a fascinating exercise. I'd love to hear people's analysis, etc. --Karl ___ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Thank you for that summary, Jake! And for the stat lesson. :) On Dec 18, 2006, at 11:19 PM, Ⓙⓐⓚⓔ wrote: Since the 7th click is reproducible, and has little to do with the issue, you can discard the value, with a simple note... years of stat classes! conclusions: running thru the whole dom looking for a class is slow. looking for an ID (which should be unique) after getting the tags is worthless. looking for a class after getting a subset of the dom is faster than searching the whole dom. Safari is almost always faster than ff! Just what was expected! GREAT WORK! On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Hey everyone, I have results of a few more speed tests that I ran this evening at http://test.learningjquery.com/speed-test.htm Method: I clicked 10 times on each query in Firefox 2.0 and Safari 2.0.4 (See HTML source for all code, markup, etc.) I recorded the mode (most common value) and the range of values for each, all in milliseconds. @ FF2 / Safari2 1. $('#speech28') - mode: 1 / 1 - range: 0-1 / 0-4 2. $('div#speech28') - mode: 43 / 32 - range: 42-59 / 30-35 3. $('#final-speech div.final-dialog ') - mode: 5ms / 5ms - range: 4-6 / 3-6 4. $('#final-speech .final-dialog') - mode: 6 / 5 - range: 5-8 / 3-6 5. $('div.final-dialog') - mode: 55 / 40 - range: 28-253 / 40-45 6. $('.final-dialog') - mode: 101 / 51 - range: 83-306 / 51-68 *** Note that queries 5 and 6 have huge ranges in Firefox because of the mysterious seventh click issue. Looks like these tests confirm what we've all been saying on this list about the relative speed of various selectors. This has been a fascinating exercise. I'd love to hear people's analysis, etc. --Karl ___ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
If you want some more detail (and have Firefox with Firebug 1.0 Beta installed), you can head on over to http://aheimlich.freepgs.com/tests/jquery/speed-test-firebug/ where I replicated Karl's tests using Firebug 1.0 Beta's script profiling abilities. The results aren't much different from Karl's, but there's still some interesting stuff there like: $(.dialog) does 815 function calls () $('#speech28') does 6 function calls On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Thank you for that summary, Jake! And for the stat lesson. :) On Dec 18, 2006, at 11:19 PM, Ⓙⓐⓚⓔ wrote: Since the 7th click is reproducible, and has little to do with the issue, you can discard the value, with a simple note... years of stat classes! conclusions: running thru the whole dom looking for a class is slow. looking for an ID (which should be unique) after getting the tags is worthless. looking for a class after getting a subset of the dom is faster than searching the whole dom. Safari is almost always faster than ff! Just what was expected! GREAT WORK! On 12/18/06, Karl Swedberg [EMAIL PROTECTED] wrote: Hey everyone, I have results of a few more speed tests that I ran this evening at http://test.learningjquery.com/speed-test.htm Method: I clicked 10 times on each query in Firefox 2.0 and Safari 2.0.4(See HTML source for all code, markup, etc.) I recorded the mode (most common value) and the range of values for each, all in milliseconds. @ FF2 / Safari2 *1. $('#speech28') * - mode: 1 / 1 - range: 0-1 / 0-4 *2. $('div#speech28') * - mode: 43 / 32 - range: 42-59 / 30-35 *3. $('#final-speech div.final-dialog ')* - mode: 5ms / 5ms - range: 4-6 / 3-6 *4. $('#final-speech .final-dialog')* - mode: 6 / 5 - range: 5-8 / 3-6 *5. $('div.final-dialog')* - mode: 55 / 40 - range: 28-253 / 40-45 *6. $('.final-dialog')* - mode: 101 / 51 - range: 83-306 / 51-68 *** Note that queries 5 and 6 have huge ranges in Firefox because of the mysterious seventh click issue. Looks like these tests confirm what we've all been saying on this list about the relative speed of various selectors. This has been a fascinating exercise. I'd love to hear people's analysis, etc. --Karl ___ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Ⓙⓐⓚⓔ - יעקב ʝǡǩȩ ᎫᎪᏦᎬ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/ -- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
On 12/19/06, Aaron Heimlich [EMAIL PROTECTED] wrote: $(.dialog) does 815 function calls () Whoops! that should be: $('.dialog') does 851 function calls () -- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi, looking for an ID (which should be unique) after getting the tags is worthless. Well, it shouldn't be. I might whant to hide an Element with the id myid only if it is an image. Then I'd try first $('img#myid').hide() and expect it to work like $('#myid').filter('img').hide(). Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
Hi, $(.dialog) does 815 function calls () $('#speech28') does 6 function calls That is not very surprizing. $('#speech28') only needs to call getElementById() and make a jQuery Object from it. $('.dialog') gets all elements, puts them into an array and filters that array for the classnames. Maybe that could be optimized by filtering while walking the tree. Then only the matching Elements would be put into the array and it doesn't need to be filtered afterwards. Christof ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] More DOM Query Speed Tests
2006/12/19, Christof Donat [EMAIL PROTECTED]: Hi, looking for an ID (which should be unique) after getting the tags is worthless. Well, it shouldn't be. I might whant to hide an Element with the id myid only if it is an image. Then I'd try first $('img#myid').hide() and expect it to work like $('#myid').filter('img').hide(). ID should be uniqe over the page, so div#myid is redundant. $('.dialog') does 851 function calls () is what scares me -- Dragan Krstić krdr http://krdr.ebloggy.com/ ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/