News for hackers. Stuff that matters.
Re:You might not need jQuery (2014) by galaxyLogic on Thursday January 14, 2021 @02:13AM (#25773162)
> In every single example, the jQuery version is basically one or two lines of code, versus 10-15 lines for the alternative

But isn't the point here that you can wrap the 10-15 lines into your own function which you can then call with just a single line of code?

So you "might not need JQuery" because you can program it yourself following the examples given, and can choose which parts of it you need and want to package with your app.

Re:You might not need jQuery (2014) by catmanjan on Thursday January 14, 2021 @02:28AM (#25773281)
I've done this before - you just end up rewriting jQuery hehe.
Re:You might not need jQuery (2014) by DarkWiiPlayer on Thursday January 14, 2021 @03:45AM (#25773800)
You'd end up writing a subset of jQuery that only has the parts you need and skips those where you almost wouldn't gain anything.
Re:You might not need jQuery (2014) by 3131s on Thursday January 14, 2021 @03:56AM (#25773879)
Well, except that jQuery and a number of third parties have already extracted or ported various subsets of jQuery and have packaged it already for easy integration.
Re:You might not need jQuery (2014) by galaxyLogic on Thursday January 14, 2021 @01:50PM (#25780467)
That's a good solution if you need such a subset. But maybe you need just a single function.

And maybe such a single function is currently already provided by the browser APIs.

Or maybe there are packages of individual functions of JQuery? But that would serve little purpose IF the functionality is provided by current browsers.

In any case I think the article serves a good purpose in explaining what are the most useful parts of JQuery and how you could implement them yourself with the more modern browsers if and when you need them.

My preference is to avoid dependencies if I can and prefer depending on my own code which uses standard APIs if possible.

Re:You might not need jQuery (2014) by catmanjan on Thursday January 14, 2021 @06:25AM (#25775087)
Over time you end up adding just about everything back in as the app grows... But worse!
Re:You might not need jQuery (2014) by galaxyLogic on Thursday January 14, 2021 @01:57PM (#25780562)
Probably not for any given single app. Some apps need more JQuery-like functionality some less
Re:You might not need jQuery (2014) by mschuetz on Thursday January 14, 2021 @04:26AM (#25774097)
But if I need to wrap around everything, I might was well just use jQuery.
Re:You might not need jQuery (2014) by cheph on Thursday January 14, 2021 @02:33AM (#25773308)
> So you "might not need JQuery" because you can program it yourself following the examples given, and can choose which parts of it you need and want to package with your app.

You could do that for any software, not sure what you gain from doing it though.

Re:You might not need jQuery (2014) by galaxyLogic on Thursday January 14, 2021 @02:04PM (#25780662)
Your app becomes smaller and easier to maintain and understand because it has fewer dependencies.

Of course if you need much of the functionality of JQuery then it is a perfect fit for you.

Note there is a cost to JQuery associated with learning and understanding what exactly each function of its API does. If you have paid that cost already by using JQuery and thus learning it, and you need it, then it makes sense to keep on using it.