r/Frontend • • Feb 13 '19

Bootstrap 5 will remove jQuery as a dependency

https://github.com/twbs/bootstrap/pull/23586
44 Upvotes

22 comments sorted by

21

u/magenta_placenta Feb 13 '19

jquery still does a lot of incredibly useful stuff. The best advertisement for jquery, ironically, is this site: http://youmightnotneedjquery.com/ Look at how simple things are in the left column, and how much more code is needed in the right column.

jquery has many convenience features such as chaining, for example: item.addClass('selected').siblings().removeClass('selected'); and you don't have to check for nulls after each selection.

Many functions such as closest() and remove() have no equivalents in IE11, and other things such as replaceWith() and before() are not available even in Edge.

For simple sites it is easy enough to remove jquery, but for more complex javascript applications, especially apps that have a lot of interactivity, removing jquery will result in more code, or you will end up writing a lot of utility functions thereby creating your own little clone of jquery.

Also, I'm sure a lot of sites and apps that use BS5 will continue to use jquery for other things anyway (all it takes is one plugin) so, in reality, a lot of BS5 sites won't have less code.

jquery may be outdated from a javascript point of view, but nothing beats its syntax. Nothing is as simple and straightforward. It's not cool anymore but there's little compelling reason to tear it out of existing projects other than a refactor. It still works great.

4

u/[deleted] Feb 13 '19

I'm not surprised you're getting downvoted but I agree, I still love jQuery, it still works great, for a ton for of situations i don't need anything else.

0

u/[deleted] Feb 13 '19

believe me more complex applications, even with lots of interactivity don't use jquery.

5

u/crazedizzled Feb 13 '19

That's fine. But if you want simple things like playing with forms, menus, toggles, ajax, modals/dialogues, etc....jquery is fine. It's a single library and requires absolutely no compilers or transpilers, doesn't need 100's of external dependencies, doesn't need bundlers, none of that shit.

jQuery is still useful.

2

u/iownacat Feb 13 '19

You say that like its a bad thing. We are professionals. Im not going to use an inferior framework or library just so I dont have to use webpack.

The real problem is jquery and things like react fight over mutating the dom, so its a really big problem using jquery in more modern applications. Even if they released BS5 with jQuery, they are going to have to rip most of the jQuery out for the React version.

2

u/crazedizzled Feb 13 '19

Im not going to use an inferior framework or library just so I dont have to use webpack

I would, if the situation calls for it. No need to over complicate everything just to look cool.

-1

u/iownacat Feb 13 '19

to "look cool?" Im talking about a superior and more productive library. If you are building some toy and dont need it, great, knock yourself out. But it has nothing to do with "looking cool."

1

u/crazedizzled Feb 14 '19

"Superior and more productive". I'd argue that not having to have a big complicated build process that has to be replicated among developers, when you don't need it, is being "more productive". I'd argue that writing one line of code to do XYZ is "more productive" than having 13 different structured components using all the best OOP practices and latest ES6 features.

In the professional world, simple is better. Easy is better. If you actually need the features that Vue or React bring, then of course that would be the right tool. If you're only using Vue for some simple dom manipulation, you're probably wasting a bunch of time.

1

u/iownacat Feb 14 '19 edited Feb 14 '19

Yeah most of that is pretty obvious, but Im obviously not talking about simple websites, Im talking about actual software development. Like I said, if you need something simple, sure, but thats not the type of work we are doing these days. And most of what you are talking about is just not that complicated, in fact its easier. ES6 is much easier and "simpler" as you say, than vanilla js, if you are accustomed to actual programming languages.

1

u/crazedizzled Feb 14 '19

but thats not the type of work we are doing these days.

Well, that's a pretty broad statement.

0

u/herjin Feb 13 '19

So, check it out. Take the right side things and make them reusable functions that you can import into your application where needed. Boom, all the benefits of the left side without a(nother) library.

1

u/[deleted] Feb 13 '19

it will happen during 4x. there's a branch in the repo for it.

https://github.com/twbs/bootstrap/tree/v4-without-jquery

did you just stumble upon this nearly 2 year old thread and decide it wasn't worth looking further into?

0

u/[deleted] Feb 13 '19

[deleted]

3

u/DOSMasterrace Feb 13 '19

Because native javascript methods have begun to simplify and standardize to the point where there's far less benefit using jQuery compared to ten-plus years ago.

1

u/kjriowhjowhjguo Feb 15 '19

I love jQuery, I started using it when it first came out and was in a small battle with mootools and prototype.js.

A lot of the capability has been appropriated by browsers, but the convenience and beautiful API that features group operations, chainings, null handling, cross-browser compatibility, etc makes it a compelling library.

That said, I've been doing this for the last 14 years, and the imperative model of writing front end code is outdated at this point. Declarative frameworks (React, Vue, etc) simplify rendering and make it more simple to understand and more maintainable.

The jQuery/imperative way is easy to get out of sync if you aren't careful to avoid side effects. Do you really want to be adding and removing table rows based on AJAX call results manually using jQuery, or do you want to say "This table should render like this" and inject data into it and have it magically update itself?

1

u/iownacat Feb 13 '19

Modern libraries like React fight with jQuery over mutating the DOM.

-3

u/Renive Feb 13 '19

Because frameworks like React Angular Vue invalidate its usage hard. You should never ever manually manipulate dom.

2

u/crazedizzled Feb 13 '19

You should never ever manually manipulate dom.

Depends on your needs. It's not really worth going through the hassle of something like React just to add a simple node after an event.

-1

u/Renive Feb 13 '19

But never mix it. Either you go React/Angular/Vue fully commited, or you don't.

3

u/crazedizzled Feb 13 '19

If you're starting a new project, no of course not. But mixing is a good strategy for migrating an old legacy jQuery app.

0

u/Renive Feb 13 '19

Yes, but in project, which is collection of pages, not in pages.

1

u/herjin Feb 13 '19

Curious to hear your opinion about this. There are plenty of examples of gradually updating an application to Vue or React one component at a time.

0

u/Renive Feb 13 '19

You can with both of them, not so much Angular, but if you had your frontend based on dom manipulation directly its a tectonic shift and most likely you migrate pages fully. You dont have to do all of them at once, that's unreasonable but dont leave pages mixed.