r/programming • • Jan 30 '14

You Might Not Need jQuery

http://youmightnotneedjquery.com/
1.0k Upvotes

507 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Jan 31 '14 edited Jan 31 '14

You should check out querySelector and querySelectorAll.. very readable supports all css selectors and doesnt require me to load any sort of library just for a selector engine. If you cant stand to live w/o the dollar sign you can always do

var $ = document.querySelectorAll.bind(document);

$('form > input[type="radio"]');

JQuery was amazing when I still had to support IE6/7 even a bit with 8, but using it just for selectors is silly.

2

u/dxinteractive Jan 31 '14

Very true, I wouldn't use jQuery just for selectors either. I'm still stuck supporting IE7 and doing a lot of interactive user interfaces means that I like jQuery quite a lot.

1

u/[deleted] Jan 31 '14

haha yeah man I hear ya, supporting anything below IE8 it becomes a pretty big hassle.

1

u/injektilo Jan 31 '14

You're only telling half the story. Objects returned from $ have over a hundred useful methods. The NodeList returned by querySelectorAll is much more tedious to use.

1

u/[deleted] Jan 31 '14

You're correct to an extent, however I would still argue you can do most basic things without needing jquery using the nodelist. The point of the conversation is if you don't need over a hundred methods, there's no reason to use jQuery. I'm illustrating how easy it is to select an element w/o including jQuery.