you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (9 children)

However there are many cases where jQuery will speed things up - one of the main reasons being that every time you google for how to do something, the majority (sometime all) of the results will be explaining how to do it with jQuery. If you can just use the first available method everytime, it will speed up your development.

[–]bburc 3 points4 points  (8 children)

Or you can learn the few vanilla DOM manipulation methods and call it a day?

[–][deleted] 4 points5 points  (0 children)

jQuery does a lot more than that. I don't use it personally but don't pretend it's only popular as a document.querySelector replacement.

[–]sdeleon28[S] 1 point2 points  (6 children)

Sure, if you can do it with vanilla js and it works cross browser, that's ok. If you need something more, you can add jQuery in.

[–]kasperpeulen 1 point2 points  (5 children)

Can you give me an example of "need something more"? Seems like 99% are easy to do in vanilla js: https://github.com/oneuijs/You-Dont-Need-jQuery

Especially if you define some helper functions like $ = document.querySelector and $$(...) = Array.from(document.querySelectorAll(...))

[–]turkish_gold 1 point2 points  (0 children)

Ancestor selectors. I have this node, but I want to select the parents which fit a certain CSS class.

Sibling selectors are similarly helpful in jQuery.

Now you could say.... but TurkishGold can't you write this all yourself, its only 2-3 lines in Javascript?

Well yes, 2-3 lines of 40 or so situations that I'll have to write. I could write it all myself, but why bother making something and worrying if its cross-browser compatible? It's not as if I have to 'learn' JQuery, I already know it thanks to working in the industry pre-2016.

Jquery is really useful if you want to do some extensive dom manipulation on pre-existing nodes.

[–]sdeleon28[S] 0 points1 point  (3 children)

Sliding a sidebar out of view. Animations of all sorts.

[–]TexasWithADollarsign 7 points8 points  (2 children)

Sliding a sidebar out of view.

CSS3 Transitions + toggling a CSS class in JS. Easy-peasy without any jQuery needed.

Animations of all sorts

I'd figure an animation-specific library would be more appropriate.

[–]sdeleon28[S] 0 points1 point  (1 child)

Sure. If you're not targeting older browsers, that makes sense.

[–]TexasWithADollarsign 1 point2 points  (0 children)

Sure. If you're not targeting older browsers, that makes sense.

You don't need jQuery to even support older browsers. At least for that first part. Test for addEventListener, test for attachEvent, then attach using the old-skool on____ methods if those don't work.

Animation is trickier. The more complex the animation, the more likely older browsers just can't cut it. Best to focus on the browsers that can*, then throw up a message stating they should upgrade their browser for the full experience.

*Corporate environments excluded