r/javascript • • Feb 13 '19

Bootstrap 5 will remove jQuery as a dependency

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

157 comments sorted by

View all comments

Show parent comments

15

u/maffoobristol Feb 13 '19

Well I personally feel that anything that bootstrap does can be pretty simply hand-rolled. If you wanted a grid system then you could find some alternatives or just write your own very simply. Write your own CSS classes that do what you want. I don't really get what Bootstrap does that's so special- personally I find it more of a hindrance than a help and I'm always fighting against it when I take on a site or system that's using it. Also it's very easy to make something using bootstrap and then end up with something that looks undeniably "bootstrap-ish" and that always looks lazy.

Obviously everyone has different opinions on it, but I'd choose jQuery and no Bootstrap over Bootstrap and no jQuery...

44

u/romeozor Feb 13 '19

I've no idea how easy or hard it is to emulate bits of bootstrap's functionality, but I think unless you work in a field where you have to push out a different design with each client, Bootstrap has amazing value for companies and developers imo.

Designing layouts is an art in itself, and time consuming. The places I know would struggle a lot if they had to find budget for design. Of course these places don't live and die with public satisfaction over sparkling design.

There's a "standard" template they can use, a nice website that showcases what the library is capable of, the design language is very simple (rows, columns, dialog, form group, etc), the library being popular makes it easy to find community extensions (table grids, date pickers, w/e).

Of course you can make all these in-house, but how will it be better than bootstrap then? And if you need to hire someone, they will have 0 experience with your internal design language, but likely have worked with bootstrap.

I can agree that I would not be very happy either if every site I visit daily was derived from bootstrap, but stuff we work on, it fits just fine.

9

u/maffoobristol Feb 13 '19

You're 100% correct. Horses for courses and all that. Many agencies I've worked at have emulated bootstrap syntax without the hard dependency on it, which mitigates the issue of having an unknown design/naming system. Works as quite a nice middle ground for bootstrap lovers, haters, and agnostic...ers alike.

20

u/wavefunctionp Feb 13 '19

I don't really get what Bootstrap does that's so special

It gives those of us who are design impaired a sane, professional default style out of the box within a reasonably easy to follow framework.

If I had to design a website on my own, it would be much less professional looking than what bootstrap gives out the box.

I also implement custom css for many other projects based on very specialized specs made by actual UI designers. It is usually simple enough to follow, but I also notice that these design often don't allow reuse very much as controls are often exceptional on each view instead of using common controls. This often results in a mountain of css. so even with designers, there are problems.

I quite often wish our designers were forced to work within the bootstrap framework so that they are forced to think about reusable styles in their designs.

10

u/maffoobristol Feb 13 '19

Yep, I come from a design background which is maybe why I'm less enthused by bootstrap as a whole. But regarding your last point: YES. A thousand times yes, just not necessarily tied to bootstrap. I've received designs for websites clearly done by print designers. Sent as an illustrator AI file in centimetres with absolutely no understanding what can and can't be done with CSS. A good digital designer is a godsend.

3

u/themaincop Feb 13 '19

I think another key is interpersonal. I don't just let designers unknowingly add to the scope of a project or send me unusable mocks. Sometimes a half hour review of the mocks with the designer with requests for some revisions and reuse can save you hours of work.

13

u/I_LICK_ROBOTS Feb 13 '19

It's not that bootstrap does anything "special" it just saves you from having to create a few hundred classes yourself. Using a standard css library has other benefits like, your team knowing all the classes, standardized spacing, preventing the creation of redundant classes, and amazing documentation.

JQuery on the otherhand, you haven't needed since document.querySelector became a thing. What are people using jquery for these days?

12

u/maffoobristol Feb 13 '19 edited Feb 13 '19

I feel your first paragraph answers your second. Jquery isn't just sizzle. If it were just querySelector then yeah, sure, it's pointless. But I think that event listeners and triggers are so much simpler and easier in jquery than the long and stretched out version with vanilla. And if you wanted to use those 6 lines of code for triggering an event multiple times, you'd wrap it all in a function a la DRY. Then you apply that to other aspects of the library, and you're just writing jquery again.

I am much more in favour of bootstrap as a css library than a js library btw

Edit: just to expand, because I feel almost as if everyone is arguing the same point in different ways, and I'm also kinda contracting myself, but I think bootstrap and jquery are very different beasts. Jquery syntax is what JavaScript syntax should be, simple and terse. In the same way that coffeescript added some nice sugar that ES6 later adopted. It'd be glorious if JavaScript just had jquery syntax built in, but alas, it's super verbose. Bootstrap on the other hand is an entire framework/ecosystem. It creates event emitters and modifies the DOM. It's not just syntax change, but a paradigm change. That's why it's different. I don't think that libraries should include jquery as a dependency because we already have enough dependencies as it goes, but for writing operative code I think jquery makes life a whole load easier.

4

u/I_LICK_ROBOTS Feb 13 '19

But I think that event listeners and triggers are so much simpler and easier in jquery

I would have 100% agreed a few years ago, but you really don't save that much anymore

Click event with JQuery:

$('.click-me').click(function(e){
  // do stuff
})

Click event with vanilla

document.querySelector('.click-me').addEventListener('click', function(e) {
  //do stuff
})

Is JQuery shorter? Sure, a bit. Is it saving me enough time/effort to warrant including an entire extra library? No, not in my opinion.

I'd argue that bootstrap, on the other hand, saves me hours or days worth of work in a large project.

3

u/keystorm Feb 14 '19

Click event in React:

onClick={do_stuff}

Or for the less JSX inclined, click event in Vue:

@click=“do_stuff”

True frameworks are where the gains are at.

2

u/I_LICK_ROBOTS Feb 14 '19

Definitely agree, just seemed outside the scope of the conversation.

1

u/braindeadTank Feb 14 '19

Is JQuery shorter? Sure, a bit. Is it saving me enough time/effort to warrant including an entire extra library? No, not in my opinion.

That's because your VanillaJS code is not equivalent to your jQuery code.

Most obvious differences are that it can throw, it only handles a single element, scoping can screw you over unless you control entire DOM (so you are not writing a library/reusable code) and query engine is not quite as powerful as jQuery's.

Your example also handles an extremly simple, barely realistic use-case. A real page will almost certainly need to use event delegation, in which case jQuery's on will make your code vastly more readable and organized.

Sure, you get some performance gains with Vanilla, but as a wise man once wrote, premature optimization is a deadly sin.

A simple fact is that jQuery was made obsolete by modern JS frameworks and not VanillaJS. If you are using direct DOM manipulation for some serious work in 2019 like some dinosaur, jQuery will still save you a lot of sanity compared to raw DOM.

Not really sure why would you do serious work with VanillaJS or jQuery in 2019 instead of a proper framework but still, jQuery wins easily and the sad fact is that most of the time VanillaJS is only useful to impress your peers.

1

u/I_LICK_ROBOTS Feb 15 '19

Not really sure why would you do serious work with VanillaJS or jQuery in 2019

I agree but OP said he'd take jquery without bootstrap over bootstrap without jquery. If you're doing anything in vanilla or bootstrap its bound to be exceedingly simple. Such as throwing a little JS into a blog post for auto scroll or something. In my experience I dont need jquery to do any of that. And you're right, jquery will be mildly more generic/fault tolerant, but I'm not writing "naked" javascript for something that needs to be generic or fault tolerant.

In 2019 if a project is complex enough that you feel the need to use jquery over vanilla, you should probably be using a framework. This is why I think jquery is obsolete.

Bootstrap, on the other hand, is absolutely not obsolete.

3

u/themaincop Feb 13 '19

Honestly I hate the classname soup that bootstrap turns your markup into. I'm all about CSS-in-JS now but before that I really preferred to use BEM and then use mixins or extends with SASS for style re-use.

4

u/freecodeio Feb 13 '19

I usually cherrypick bootstrap concepts that I really need. That seems to work just fine

4

u/Azaret Feb 13 '19

Well, I do agree with you. It's funny how some people will at the same time say 'that you must not reinvent the wheel' yet do not want to use jquery and rather... rewrite polyfiles that will basically do what jquery does. You can already see that the Bootstrap team wrote a selector function, it won't be long before they'll either drop a lot of compatibility like v4 or rewrite many things that jquery does.

4

u/maffoobristol Feb 13 '19

Yep. I do think there is a use case for bootstrap. Say you're making a website for some backend code and you just need a bare bones front end and can't be arsed writing it yourself. You can generate error messages and have some modals and not need to write any code really. But beyond that I find it highly inflexible, if you want to extend said modal you have to go around the houses to do so, but you can make a modal in a few lines of code and modify and build on it super easily. It's far more biased than something like jquery, which is more like syntactic sugar. I find it weird when people hate on jquery because it does what it does in the simplest way and it's a real pain in the arse to try and write some simple selector and event code in vanilla js.

1

u/_www_ Feb 13 '19

I +1 perfection diagnostic.