Live data from Hacker News

You might not need jQuery

youmightnotneedjquery.com

21–30 of 360 posts

Re: You might not need jQuery

#21
You had me convinced until I scrolled down to read the code examples and realized why I actually do need jQuery. If its between adding yet another collection of utility functions to approximate the functionality jQuery would give me vs just adding jQuery. I'd rather go with jQuery.

Re: You might not need jQuery

#22

I understand the desire for people to make pages like this (this isn't the first), but the examples are not completely honest with themselves, in my opinion. One of the biggest benefits jQuery introduces is the concept of treating single selections and multiple selections identically. While using jQuery, I can emit a $(".class").hide() call, which will apply to all elements with the matching class. Simple and elegant…

"You might not need jquery"

Re: You might not need jQuery

#23
In my opinion jquery is a hell. Because jquery is only abstraction for browser features level (events, styles, dom), but it's ugly for writen complete code, for this need some like prototype.js or mootools, because it's have oop-style level for browser.

Re: You might not need jQuery

#24

It's hard to tell if this site is advocating for ditching this type of js library altogether and writing all those replacements inline (ick for some of those) or simply replacing jQuery with a thinner (and narrower) library. I could be convinced of the latter but not the former.

I think that what it's saying is that you can write yourself a microlibrary that just includes the ten or fifteen lines of adapter code you actually need for the thing you're building, and that you should use native browser constructs whenever possible.

Re: You might not need jQuery

#25
post #11

> in truth, post-IE8, browsers are pretty easy to deal with on their own I totally agree, but not everyone lives in a post-IE8 world. It's as much as 10% of our traffic on some sites and several big clients use it.

That's why it's called You_Might_NotNeedJQuery. ;)

Would be great if we could all stop recapitulating this, it's not helping

Re: You might not need jQuery

#26
"You might not need Ruby on Rails. Use C to rewrite tons of shit you need."

Use jQuery please.

Rewriting jQuery methods with vanilla js usually turns out to be a hack job that is buggy and ugly. Just use jQuery.

Re: You might not need jQuery

#27

It's hard to tell if this site is advocating for ditching this type of js library altogether and writing all those replacements inline (ick for some of those) or simply replacing jQuery with a thinner (and narrower) library. I could be convinced of the latter but not the former.

One of the main things we're advocating is to consider not depending on jQuery when building an open-source project.

For Offline, PACE, Odometer, Tether, and many of our other OS projects (http://github.hubspot.com), we chose not to depend on jQuery because it means our libraries can be smaller and more people can use them.

We're happy and proud to use jQuery when building an application. As many other commenters have noticed, it can be extremely useful at reducing code complexity—and let's just say it: it can make it more enjoyable to write front-end code!

Re: You might not need jQuery

#28
post #21

You had me convinced until I scrolled down to read the code examples and realized why I actually do need jQuery. If its between adding yet another collection of utility functions to approximate the functionality jQuery would give me vs just adding jQuery. I'd rather go with jQuery.

One way of looking at it is that if you already have underscore to give you _.extend and the like, you can get pretty far with just what the browser gives you.

Re: You might not need jQuery

#29
post #17

What's a good resource to read up on how browsers handle unsupported JS, if I want to write a fall-back? I've already got fall-back for people who've turned off JS, but I've yet to write anything for unsupported JS.

This might be overkill for you, but take a look at http://modernizr.com/

Sometimes it's just as simple as testing if the function your about to call exists before you call it.

Re: You might not need jQuery

#30
querySelector and querySelectorAll have bugs in IE8. Checkout the jQuery source code and search for these functions and see the comments and workarounds if you want to be sure:

http://code.jquery.com/jquery-1.11.0.js

Notice the rbuggyQSA variable.

Also check out Quirksmode:

http://quirksmode.org/dom/core/

Post reply on HN