On Feb 27, 12:42 am, John Resig wrote:
> > The benchmark is getElementById().getElementsByTagName() - why not
> > inlcude that in the test?
>
> But it's not that simple (it never is). That code doesn't take into
> account browsers, like IE, returning element that have a name equal to
> the ID,
You maybe know this, but there's a great website that compares
compatibility in different popular browsers:
http://www.quirksmode.org/dom/w3c_core.html
I've noticed lately to the "querySelectorAll" method. Looks
promising :)
more to see here:
http://www.quirksmode.org/compatibility.html
--
D
For anyone interested, here is the updated set of 'tests' for the test
page I posted previously. This is the test-set John is currently
using:
// Test # 1
start = new Date();
$Test = $("#div"+ myDiv +" p");
end = new Date();
a_Selectors.push('$("#div'+ myDiv +' p")');
a_Times.push(end - s
> The benchmark is getElementById().getElementsByTagName() - why not
> inlcude that in the test?
But it's not that simple (it never is). That code doesn't take into
account browsers, like IE, returning element that have a name equal to
the ID, not does it take into account the element (with the I
On Feb 26, 11:22 am, John Resig wrote:
> Ok, fixed the perf regression. Here's the
> commit:http://dev.jquery.com/changeset/6261
>
> In Firefox 3.0.6 I'm now getting (on my local copy):
> Query version used = 1.3.3pre
> Total number of DIVs = 1000
> Paragraphs per DIV = 500
>
> $("#div500
Ok, fixed the perf regression. Here's the commit:
http://dev.jquery.com/changeset/6261
In Firefox 3.0.6 I'm now getting (on my local copy):
Query version used = 1.3.3pre
Total number of DIVs = 1000
Paragraphs per DIV = 500
$("#div500 p") = 19ms
$("p", "#div500") = 2ms
$("#div500").find("p")
@John: I found a little bug in your v1.3.3 test version...
This selector works fine in FireFox, but bombs out in IE7...
$("#div50 p")
IE7 --> "Object doesn't support this property or method"
But this works fine:
$("#div50 > p")
NOTE that I'm pulling v1.3.3 directly from your personal c
> WOW! Check out the last 2 tests, John. Syntax #4 takes 512-times
> longer than #5! I think this code needs a little TLC too ;)
>
> It was also interesting that $("#div500").children("p") is 10-times
> slower than $("#div500").find("p"). So I added one final test using
> childNodes and filter() t
That's a fantastic improvement. But now I have a new challenge - keep
reading...
To see if there really is a difference between the 2nd and 3rd
options, or whether it is just 'variance', I cranked up the DIVs & Ps
and tried both versions again:
ALL tests below are in FireFox 3.0.6
--
To follow-up from my post yesterday, here are the new numbers, for
1.3.3 (work in progress, naturally):
http://ejohn.org/files/jquery1.3.3/id.html
jQuery version used = 1.3.3pre
Total number of DIVs = 100
Paragraphs per DIV = 50
---
$("#div50 p") = 2ms
$("p", "
FYI, I built a quick test page for this. As previously noted, the
differences in v1.2.6 are relatively small - about 2x as long for one
syntax over the other. But with 1.3.2 - Wow! - 60x longer!
jQuery version used = 1.3.2
Total number of DIVs = 100
Paragraphs per DIV = 50
---
ortcut.
>
> -- Josh
>
> -Original Message-
> From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
>
> Behalf Of Kevin Dalman
> Sent: Wednesday, February 25, 2009 10:41 AM
> To: jQuery (English)
> Subject: [jQuery] Re: $('#foo p') or
Wednesday, February 25, 2009 10:41 AM
To: jQuery (English)
Subject: [jQuery] Re: $('#foo p') or $('p', $('#foo'))
John wrote: "You should always use $("#foo").find("p") in favor of $
("p", $("#foo")) "
I'm trying
John wrote: "You should always use $("#foo").find("p") in favor of $
("p", $("#foo")) "
I'm trying to extrapolate some general concepts from this 'rule'...
First, I *assume* these two statements are identical in performance:
$("p", $("#foo")) == $("p", "#foo")
If so, then does it matter what t
On Feb 24, 6:10 pm, Jon Sagotsky wrote:
> Just to clarify, $("p", "#foo") would be meaningless
That's not true. $('p', '#foo') has the exact same result as $('p', $
('#foo')), the context is executed just as well.
Liam,
$() can take one or two arguments. The first argument is what your
searching for. The second argument is the context in which you are
searching. If you only use one argument, the second defaults to the
whole dom.
$("#foo p") searches for all p in #foo. It does this by getting every
p e
I want to point out a couple things:
1) You should always use $("#foo").find("p") in favor of $("p", $
("#foo")) - the second one ends up executing $(...) 3 times total -
only to arrive at the same result as doing $("#foo").find("p").
2) I generally dislike saying that there's one good way to do a
Liam,
I think you're thinking of $("p, #foo").
Notice it's the difference between two params being passed in to the
selector function (the original question) vs a single param that
happens to be a comma separated list of selectors.
On Feb 24, 6:00 am, Liam Potter wrote:
> lol, but I'm interest
Hi Karl,
$('#foo').find('p') and $('p', $('#foo')) are approximately of the same speed.
I've put the test code on JSBin, so everybody can play around with it
and try other combinations :-)
http://jsbin.com/ifemo
by(e)
Stephan
2009/2/24 Karl Swedberg :
> Hi Stephan,
> Thanks for doing this tes
Hi Stephan,
Thanks for doing this testing! Would you mind profiling $
('#foo').find('p') as well? I suspect it will be roughly equivalent to
$('p', $('#foo'))
Cheers,
--Karl
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 24, 2009, at 8:28 AM, Stephan Veig
Hi Lima,
taking a look at $("p", $("#foo")) you see that the second parameter
is a function: $("#foo").
This function is evaluated first and returns the jQuery object for #foo.
Then the surrounding $("p",...) function is called with the jQuery
object for #foo as second parameter.
The documentatio
http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.js
Or you can read jquery documentaion. I also suggest "Learning jQuery"
by Karl Swedberg and Jonathan Chaffer.
Read jQuery HowTo Resource - http://jquery-howto.blogspot.com
On Tue, Feb 24, 2009 at 7:00 PM, Liam Potte
lol, but I'm interested in what jquery does with what I tell it.
jQuery Lover wrote:
That is how it works Liam !!! jQuery does not knows, it's told so...
Read jQuery HowTo Resource - http://jquery-howto.blogspot.com
On Tue, Feb 24, 2009 at 6:49 PM, Liam Potter wrote:
ok, but wh
Thanks Stephen! I gave your reply a 5 star rating because you deserve
it.
On Feb 24, 1:28 pm, Stephan Veigl wrote:
> Hi,
>
> I've done some profiling on this, and $("p", $("#foo")) is faster than
> $("#foo p") in both jQuery 1.2.6 and 1.3.2.
>
> the test HTML consists of 100 s in a "foo" and 90
That is how it works Liam !!! jQuery does not knows, it's told so...
Read jQuery HowTo Resource - http://jquery-howto.blogspot.com
On Tue, Feb 24, 2009 at 6:49 PM, Liam Potter wrote:
>
> ok, but what in jquery knows that $("p", $("#foo")) should look for the p
> tags inside of #foo, w
ok, but what in jquery knows that $("p", $("#foo")) should look for the
p tags inside of #foo, why does it treat it like $("#foo p")?
jQuery Lover wrote:
Liam, you can use $("p", "#foo"). The second parameter must be a
jQuery object or dom element...
Read jQuery HowTo Resource - http:
Liam, you can use $("p", "#foo"). The second parameter must be a
jQuery object or dom element...
Read jQuery HowTo Resource - http://jquery-howto.blogspot.com
On Tue, Feb 24, 2009 at 6:44 PM, Liam Potter wrote:
>
> Hi Stehpan :p
>
> I understand that, I'm just not sure why $("p", $("#f
Hi Stehpan :p
I understand that, I'm just not sure why $("p", $("#foo")) is not the
same as $("p", "#foo")
- Liam
Stephan Veigl wrote:
Hi Lima,
1) #foo is an ID and since IDs should be unique there has to bee only
one #foo element
2) $("p", $("#foo")) selects all elements in the scope of
Hi Lima,
1) #foo is an ID and since IDs should be unique there has to bee only
one #foo element
2) $("p", $("#foo")) selects all elements in the scope of the #foo element.
In other words, it selects every element under #foo in the DOM tree.
by(e)
Stephan
2009/2/24 Liam Potter :
>
> I've been
I've been following this discussion, but I need explaining why $("p",
$("#foo")) doesn't select all p tags and all #foo id's ?
Stephan Veigl wrote:
Hi,
I've done some profiling on this, and $("p", $("#foo")) is faster than
$("#foo p") in both jQuery 1.2.6 and 1.3.2.
the test HTML consists o
Hi,
I've done some profiling on this, and $("p", $("#foo")) is faster than
$("#foo p") in both jQuery 1.2.6 and 1.3.2.
the test HTML consists of 100 s in a "foo" and 900 s in a
"bar" .
However the factor differs dramatically:
In 1.2.6 the speedup from $("p", $("#foo")) to $("#foo p") was betwe
up to jQuery 1.2.6 that's how the selector engine worked (from the top
down/left to right). The approach used in Sizzle (bottom up/right to
left) has both benefits and downsides - it can be much faster on large
DOMs and some situations, but slower on short queries. I'm sure
someone can explain tha
On Mon, Feb 23, 2009 at 11:08 AM, Peter Bengtsson wrote:
>
> I watched the John Resig presentation too and learned that CSS
> selectors always work from right to left.
> That would mean that doing this::
>
> $('#foo p')
>
> Would extract all tags and from that list subselect those who
> belong
33 matches
Mail list logo