Hacker News new | ask | show | jobs
by galaxyLogic 1983 days ago
> 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.

3 comments

I've done this before - you just end up rewriting jQuery hehe.
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.
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.
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.

Over time you end up adding just about everything back in as the app grows... But worse!
Probably not for any given single app. Some apps need more JQuery-like functionality some less
But if I need to wrap around everything, I might was well just use jQuery.
> 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.

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.