[jQuery] Re: selector best practice

2009-02-18 Thread Henrik Javén
Your test case is not comparing a raw implementation You are still using jQuery $ inside the loop, it should be pure document.getElementById("test"); When you remove the $ from your test case and use native implementation you will be getting numbers in the following range: FF ID Raw: 1 ID jQuer

[jQuery] Re: selector best practice

2009-02-17 Thread RobG
On Feb 17, 4:22 pm, SteelRing wrote: > I would love to get to the bottom of all these and figure out cases of > "recommended" and "bad" uses of jquery selector. I came across jquery > a couple months ago and got excited with how easy it is to use this > framework rather than doing getElementFro

[jQuery] Re: selector best practice

2009-02-16 Thread SteelRing
I would love to get to the bottom of all these and figure out cases of "recommended" and "bad" uses of jquery selector. I came across jquery a couple months ago and got excited with how easy it is to use this framework rather than doing getElementFromMyAss all over the page, typing that long synta

[jQuery] Re: selector best practice

2009-02-16 Thread RobG
On Feb 17, 2:43 am, John Resig wrote: > On Mon, Feb 16, 2009 at 8:28 AM, RobG wrote: > > > On Feb 16, 5:30 pm, SteelRing wrote: > >> This may sound stupid to y'all jquery practitioners, but i wonder > >> which method is fastest (recommended) for selecting a cell with a > >> class in a big ta

[jQuery] Re: selector best practice

2009-02-16 Thread John Resig
Umm - that's not true at all. I created a test for you to see: http://dev.jquery.com/~john/ticket/class-speed/ In Firefox 3 I'm getting: ID Raw: 9 ID jQuery: 22 (over 500 queries) Class Raw: 1108 Class jQuery: 778 (over 100 queries) In Safari 3.2 I'm getting: ID Raw: 1 ID jQuery: 3 (over 500 qu

[jQuery] Re: selector best practice

2009-02-16 Thread Ricardo Tomasi
Not going to native methods I'd say the fastest selector without an ID would be $("#tableid td.cellclass") as that will call getElementByID and getElementsByTagName/getElementsByClassName from the #tableid context (or querySelectorAll). Anyway, you only need to add more selectors if you want to en

[jQuery] Re: selector best practice

2009-02-16 Thread RobG
On Feb 16, 5:30 pm, SteelRing wrote: > This may sound stupid to y'all jquery practitioners, but i wonder > which method is fastest (recommended) for selecting a cell with a > class in a big table (think like 1000+ rows 100+ columns): Fastest: the browser-native getElementsByClassName (recent

[jQuery] Re: selector best practice

2009-02-15 Thread Rene Veerman
I'd say go for just ("#uniqueid") as that likely maps to document.getElementById() (fast) and bypasses the normal jquery traversing that is required if you put in more selectors. SteelRing wrote: This may sound stupid to y'all jquery practitioners, but i wonder which method is fastest (recom