jQuery Selectors Quiz - Test Your Knowledge

G

Garrett Smith

Test your jQuery selectors knowledge with the jQuery Quiz!

10 questions long.

Read the instructions carefully and how many tries it takes you to get
it right.

When you've successfully answered all 10 questions correctly, you'll get
to see the demo of them in action, linked from the bottom of the quiz.

http://dhtmlkitchen.com/jstest/jquery/quiz.jsp

Garrett
 
N

nick

When you've successfully answered all 10 questions correctly, you'll get
to see the demo of them in action, linked from the bottom of the quiz.

Got some issues with the scoring...

"Good job! After just 1 try, you got all 10 questions right!"

...but I only got two right (7 and 9). Now I'm really curious what the
right answers were? I'm guessing the non-strings are allowed, and the
image inputs are getting treated as img tags or vice versa?
 
D

David Mark

On 2/06/2010 7:34 AM, Garrett Smith wrote:
[...]
The URL gives
Service Temporarily Unavailable

Try it again.

I'm working out issues with the configuration of Tomcat where JSPs are
not reloaded.

You might want to work on the tallying as well. It counts about as
well as jQuery (and the rest of them, most of which are now
"standardizing" on jQuery's engine).

http://www.cinsoft.net/slickspeed.html

Oh, the humanity! :)

Took me three fairly disinterested tries to get them all (first after
misreading the instructions) and that goes to show the futility of
trying to predict even one version of jQuery (the latest in this case)
across multiple browsers (particularly if attribute-related queries
are involved).

The presence of QSA and non-QSA enabled browsers, as well as broken
MSHTML implementations would make for some long-winded explanations of
the results. Life's too short, so one should just realize that jQuery
is god-awful at the one thing it is supposedly proficient at and dump
it.

The retorts from jQuery-land (assuming they are even paying attention)
will range from:-

1. Nobody's perfect.
2. jQuery rulez d00d!!!!!!
3. Those are all "edge cases".
4. You're just trying to break it.
5. Where's your cool query engine?
6. Aw, UR just jealous coz nobody uses your query engine.
7. They'll get it eventually! :)
 
R

RobG

Test your jQuery selectors knowledge with the jQuery Quiz!

10 questions long.

Read the instructions carefully and how many tries it takes you to get
it right.

When you've successfully answered all 10 questions correctly, you'll get
to see the demo of them in action, linked from the bottom of the quiz.

http://dhtmlkitchen.com/jstest/jquery/quiz.jsp

The explanation for the sample error is wrong, where it says:

"In Firefox 3.6, nothing will happen, making "c" correct..."

it should say:

"...making "b" correct...".

I kept trying until #10 was marked correct - apparently "e" is the
answer. The explanation:

"Result is 1 in Firefox 3.6, IE8, Safari 4, Opera 10, IE8 (standards),
and Chrome; and 0 in IE6 and IE7 (either mode), and IE8 in quirks
mode. "

But that would make "d" the correct choice, not "e". I think more work
is needed.

If the intention is to point out inconsistencies in the Sizzle
selector engine, you're at risk of failing because of simple errors
that affect the credibility of the exercise.
 
G

Garrett Smith

The explanation for the sample error is wrong, where it says:

"In Firefox 3.6, nothing will happen, making "c" correct..."

Yes, I know and that has been fixed. Thanks.

The example question was changed to include a third correct answer,
introducing a mistake in the process. I fixed that but the change was
not picked up by Tomcat. I had to leave, and could not fix it at that time.

I kept trying until #10 was marked correct - apparently "e" is the
answer. The explanation:

"Result is 1 in Firefox 3.6, IE8, Safari 4, Opera 10, IE8 (standards),
and Chrome; and 0 in IE6 and IE7 (either mode), and IE8 in quirks
mode. "

That explanation is right and "d" is the most correct answer. I've fixed
the test.

The trick is that jQuery does not support the universal selector and so
when that is used, then the other imgs won't be matched, resulting in 0
0 is a wrong answer, which is unintersting; how jQuery gets that wrong
answer is.

Unquoted, $("html > body input[width=600]").length results

`4` in any version of IE in quirks mode (IE6 and above; IE5.5 just
throws errors with jQuery).

`1` in Firefox 3.6.

`0` in IE6 and IE7 in standards mode.

SO, unquoted, the answer would have been e.
But that would make "d" the correct choice, not "e". I think more work
is needed.

"e" would be the most correct answer because it does not include
If the intention is to point out inconsistencies in the Sizzle
selector engine, you're at risk of failing because of simple errors
that affect the credibility of the exercise.

Indubitably stupefied by my own quiz and point taken.

Valuable feedback. Thanks, Rob.

Anyone else find this stuff confusing, BTW?
 
R

RobG

On 6/1/2010 4:28 PM, RobG wrote: [...]
If the intention is to point out inconsistencies in the Sizzle
selector engine, you're at risk of failing because of simple errors
that affect the credibility of the exercise.

Indubitably stupefied by my own quiz and point taken.

I wonder whether it might be better to just state the expected
(technically correct) result, then the actual (jQuery) result and why
jQuery fails on the first attempt regardless of which answers are
given. Requiring visitors to "pass" the test to get to the interesting
part may distract from the valuable point being made.
 
G

Garrett Smith

On 6/1/2010 4:28 PM, RobG wrote: [...]
If the intention is to point out inconsistencies in the Sizzle
selector engine, you're at risk of failing because of simple errors
that affect the credibility of the exercise.

Indubitably stupefied by my own quiz and point taken.

I wonder whether it might be better to just state the expected
(technically correct) result, then the actual (jQuery) result and why
jQuery fails on the first attempt regardless of which answers are
given. Requiring visitors to "pass" the test to get to the interesting
part may distract from the valuable point being made.
The visitor at least gets the information that shows each browser doing
different things. That should give a clue that something isn't quite right.

I also showed the example links at the bottom -- let them cheat if
they're impatient. That way they can see what it really does and for the
reader who really wants to test his jQuery knowledge, he can just not
click on the link until he's done -- leave it up to the reader.

The expected technically correct result? Based on what? Selectors API
draft that I linked there?

Most of those examples should raise a SYNTAX_ERR exception.

The Selectors API[1] states:

| If the given group of selectors is invalid ([SELECT], section 13),
| the implementation must raise a SYNTAX_ERR exception

The Selector's API does not specify a context param, either.

I'm exhausted and worreid that my message may end up reflecting that in
the form of gibberish, so I'll leave it at that.

[1]<http://www.w3.org/TR/selectors-api/#security>
 
J

John G Harris

QSA - document.querySelectorAll. Handy lingo when you need to say
something in < 140 characters.

According to Wikipedia it stands for Qt Script for Applications, which
is a recently superseded ECMAScript engine.

It's better if the less common abbreviations are expanded at least once
in the threads using them.

John
 
D

David Mark

What's this QSA I see mentioned occasionally here? Google was no helphttp://www.google.com/search?q=qsa

Basically, a little while back, browsers developed the ability to do
queries, without the help of dubious scripts. Unfortunately, they are
not compatible with the popular scripts. Somehow it was decided that
the best way for such scripts to proceed was to call QSA first and on
failures use the old incompatible code. The spin was that now the old
scripts were now faster than ever (e.g. "Sizzle" was born). The
reality is evidenced here:-

http://www.cinsoft.net/slickspeed.html

....which clearly demonstrates the differences between the non-QSA and
QSA versions of several popular scripts. This caused quite the public
outcry when I published it. Though much of it was directed at me
rather than the scripts. :) After all, why would I test the old
versions? Because the new ones use QSA for 90% of the tested queries
and AFAIK offer no way to turn it off. And as we have rehashed with
this quiz, testing in older browsers is quite revealing as well. Why
does this matter? Because it demonstrates the effects of time on
sniffy multi-browser scripts. In a year, today's browsers will be on
the scrap heap too and that's just silly.
 
D

David Mark

Basically, a little while back, browsers developed the ability to do
queries, without the help of dubious scripts.  Unfortunately, they are
not compatible with the popular scripts.  Somehow it was decided that
the best way for such scripts to proceed was to call QSA first and on
failures use the old incompatible code.  The spin was that now the old
scripts were now faster than ever (e.g. "Sizzle" was born).  The
reality is evidenced here:-

http://www.cinsoft.net/slickspeed.html

...which clearly demonstrates the differences between the non-QSA and
QSA versions of several popular scripts.  This caused quite the public
outcry when I published it.  Though much of it was directed at me
rather than the scripts.  :)  After all, why would I test the old
versions?  Because the new ones use QSA for 90% of the tested queries
and AFAIK offer no way to turn it off.  And as we have rehashed with
this quiz, testing in older browsers is quite revealing as well.  Why
does this matter?  Because it demonstrates the effects of time on
sniffy multi-browser scripts.  In a year, today's browsers will be on
the scrap heap too and that's just silly.

Forgot to mention. Now roughly 98% of Sizzle's code exists to
"support" non-QSA browsers. Quotes indicate that could only be IE < 8
(and its Compatibility View), which they seem bound and determined to
stop "supporting" (and as we've seen that's a pretty strong word for
its performance in those browsers). So, if all of the supported
browsers have QSA then all you need are the roughly six lines used to
call QSA. Wouldn't it make a lot more sense to detect QSA, use it
when possible and degrade for everything else? Why use something that
is known to have tons of issues in some of the worst browsers ever
produced (e.g. IE7). Doesn't make a lot of sense, does it? Why are
all of the "major" projects dropping in 70K of outmoded (not to
mention irretrievably broken) code at this point to "support" browsers
they are all just itching to declare dead? Perhaps they haven't
thought this thing through. But then, they didn't need to as I've
explained and demonstrated these concepts ad nauseam. :)

The answer should be quite clear. If the scripts are reduced to six
lines, the associated cottage industries are out of business.
Granted, jQuery as a whole has more than just Sizzle. It's got some
element measurement methods that don't work and some very primitive
special effects (which also have issues in older versions of IE,
quirks mode, etc.) And don't forget "Live", which is a terrible way
to do basic event delegation (without learning anything of course),
relying on (you guessed it) queries. Hard to see those features as
beneficial for beginners.
 
T

Thomas 'PointedEars' Lahn

John said:
According to Wikipedia it stands for Qt Script for Applications, which
is a recently superseded ECMAScript engine.

"qSA", then?
It's better if the less common abbreviations are expanded at least once
in the threads using them.

ACK


PointedEars
 
N

news

On 6/1/2010 4:28 PM, RobG wrote: [...]
If the intention is to point out inconsistencies in the Sizzle
selector engine, you're at risk of failing because of simple errors
that affect the credibility of the exercise.
Indubitably stupefied by my own quiz and point taken.

I wonder whether it might be better to just state the expected
(technically correct) result, then the actual (jQuery) result and why
jQuery fails on the first attempt regardless of which answers are
given. Requiring visitors to "pass" the test to get to the interesting
part may distract from the valuable point being made.

I agree - out of sheer nerdiness, I kept trying till I got them all
"right", but to be honest it was an effort.

Slightly hampered by your referring to the answers as a, b, c, d etc,
but on my browser at least, them being labelled 1, 2, 3, 4 etc.

You'd make more of a point just scoring people's answers once - show
the explanation of the correct answer regardless whether they got it
right or not. The point you are making is clear ONLY when you can see
the correct answers. The people you are trying to make that point to
won't get the answers right (in fact I don't think anyone can without
the research you did), so will wander away just as confused.
 
M

Matt Kruse

I wonder whether it might be better to just state the expected
(technically correct) result, then the actual (jQuery) result and why
jQuery fails on the first attempt regardless of which answers are
given. Requiring visitors to "pass" the test to get to the interesting
part may distract from the valuable point being made.

Agreed. Obviously the point of this is to highlight the failings of
jQuery, but doing it in such a "sarcastic" way is annoying. I'd like
to see a page that just lists what jQuery gets wrong, rather than
making me study a test and pick answers. I don't have time for that,
and I don't think most people who might actually benefit from the
knowledge will take the time to actually do it.

Matt Kruse
 
G

Gregor Kofler

Am 2010-06-02 00:05, nick meinte:
Got some issues with the scoring...

"Good job! After just 1 try, you got all 10 questions right!"

..but I only got two right (7 and 9). Now I'm really curious what the
right answers were? I'm guessing the non-strings are allowed, and the
image inputs are getting treated as img tags or vice versa?

I was congratulated with the same message and had one out of ten right.
I'm somewhat puzzled what this quiz is all about...

Gregor
 
D

David Mark

Agreed. Obviously the point of this is to highlight the failings of
jQuery, but doing it in such a "sarcastic" way is annoying. I'd like
to see a page that just lists what jQuery gets wrong, rather than
making me study a test and pick answers.

As you well know, such a list would be quite voluminous and would vary
from one browser/configuration (as well as jQuery version) to the
next. Running this in multiple browsers (and reading my previous
posts in this thread) should be enough:-

http://www.cinsoft.net/slickspeed.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top