Live data from Hacker News

Bootstrap 5 will remove jQuery as a dependency

github.com

161–170 of 333 posts

Re: Bootstrap 5 will remove jQuery as a dependency

#161
post #70
post #39

This PR is massive and represents a year and a half of work. If you look at the comments you see there are loads of browser-specific issues being fixed. IE support was dropped as they didn't feel making stuff compatible (jQuery did that for them before). The API is also incompatible; in the words of one dev: "we broke everything". As one of the commenters pointed out, a lot of stuff was copied from jQuery to make it…

> As one of the commenters pointed out, a lot of stuff was copied from jQuery to make it work. > In other words, this entire effort seems of dubious benefit to me. You made other points, but I wanted to focus on this one. Yes, there's a few remaining bits that don't have standards. But you can do so much with querySelector, classlist.toggle(), lastElementChild, scrollIntoView, insertAdjacentHTML - literally every Jav…

> Side benefit: also no weird $(thing)[0] when you need to use a DOM API, like HTML5 validity or whatever.

But looping over querySelectorAll() is painful. I'm not really a frontend dev, so perhaps I'm doing it wrong, but this is the "easier" way I found when I was writing an app a few weeks ago (in TypeScript):

  // Get Array of HTMLElements from querySelectorAll().
  let queryAll = (q: string): HTMLElement[] => {
    let nodes = document.querySelectorAll(q);

    let arr: HTMLElement[] = [];
    arr.length = nodes.length;

    for (let i = 0; i 

Re: Bootstrap 5 will remove jQuery as a dependency

#162

Earlier quoted context omitted.

But this isn't replaced with a new framework that uses the shadow DOM, it uses the same techniques as jQuery, except without jQuery. jQuery already uses many native features when supported, while also working around browser quirks and such. It's less of an issue than in the past, but it hasn't gone away completely; see all the comments/fixes for specific browsers. > One less dependency, network request and more effic…

in the world of web performance and SEO 85kb is very significant. i wouldnt think twice to remove it if i had the opportunity. compared to modern frameworks, jquery is ~500% larger. you could definitely debate the usage and needs but thats a separate topic than efficiency.

These massive compressed JS bundles make me think your numbers are off on the alleged golden age of modern frameworks:

https://webpagetest.org/result/190213_XH_63c61dc3d45cb95ec8a...

https://www.webpagetest.org/result/190213_NX_ee1e7ae8fa74557...

It’s not hard to beat jQuery in many cases but they’re looking pretty svelte in comparison:

https://webpagetest.org/result/190213_93_e2da91a07e2b2bc0234...

Re: Bootstrap 5 will remove jQuery as a dependency

#163
post #48

Earlier quoted context omitted.

jQuery _did_ lots of useful stuff. It's unmaintained, has no interest/support (look at their github), doesn't adapt to modern features, is 'slow' compared to other frameworks that now use the Shadow Dom, and can be replaced with features that are native to JS - what's there not to like about that? One less dependency, network request and more efficient code is always worth the effort. Oh, and since the new code is va…

Jquery will fallback to native functions where available and it's feature complete. It doesn't need to have constant commits to still be immensely useful. Its primary purpose was smoothing over browser inconsistencies and it's cached by every major CDN already so using it is likely faster than trying to rebuild and maintain the individual parts separately.

> it's cached by every major CDN already

I’ve never found this to be true any time I’ve measured, especially for mobile clients. Small caches with lots of versions and CDNs really cut into the theoretical benefits.

Re: Bootstrap 5 will remove jQuery as a dependency

#164
post #126
post #82

Earlier quoted context omitted.

Only part of the world is moving to css-in-js. I won't be on the boat leaving for that destination.

CSS in JS isn't CSS. It's just SS. It ignores the best part of the language; the cascade.

Or the worst from my point of view. CSS rots more than any other code in a front end codebase and the methods for static analysis are incredibly limited.

Refactoring and static analysis tools are incredibly limited or nonexistent for plain CSS or SCSS (when talking about the barriers between HTML and the stylesheet).

We do all of our new views and stylesheets using React, TypeScript, and Typestyle. As a result we can expose much controlled methods of theming and have a compiler enforced link between variables, selectors, and their usages. We can refactor easily. We can catch simple typos at compile time instead of runtime, and validate them more easily in CI.

Re: Bootstrap 5 will remove jQuery as a dependency

#165
post #137

Earlier quoted context omitted.

Is SelectorEngine sizzle directly? I'm not sure how practical replacing jQuery is, and not going to look that deep. But jQuery isn't nearly as big today since most browsers (even IE11) are pretty modern.

A good replacement selector engine: `const selectorEngine = selector => Array.from(document.querySelector(selector));` :)

It needs to be querySelectorAll, and you need to handle cases where it returns null as well.

Re: Bootstrap 5 will remove jQuery as a dependency

#166
post #155

This is funny. I was thinking that Bootstrap should be suffering the same fate as jquery. That is, it’s relevance should be decreasing as web technology catches on. I see no reason for using a third party layout system now that CSS has `display: flex;` and `display: grid;`. As for modals and menus, HTML has ` ` and ` `. And for reusable components, we have custom elements, that you can either implement your self (not…

So long as native web controls are look so awful, we need something like bootstrap The layout support in Bootstrap is nice, but the baseline design language is more important

I think bootstrap looks worse than native web controls so I don't see it as a necessity like you say.

Re: Bootstrap 5 will remove jQuery as a dependency

#167

This is funny. I was thinking that Bootstrap should be suffering the same fate as jquery. That is, it’s relevance should be decreasing as web technology catches on. I see no reason for using a third party layout system now that CSS has `display: flex;` and `display: grid;`. As for modals and menus, HTML has ` ` and ` `. And for reusable components, we have custom elements, that you can either implement your self (not…

Depends entirely on the application. If your application has many basic views, you'll be wasting time writing out CSS grid properties for a basic responsive layout. I mean, at some point you'll recognize you're reinventing the wheel and just pull in a CSS grid from a framework. This applies to basically any components that has been battle tested in Bootstrap.

Indeed. Some years ago I was working on a project where I decided one day to rip Bootstrap out and reimplement everything that Bootstrap did with my own CSS. In the end I ended up pretty much just recreating Bootstrap, and after a few months it had become an unmaintainable mess.

I'm not saying that everyone should use Bootstrap, or even CSS frameworks in general, but this idea that we should avoid them because don't 100% require them is madness. The simple reality is that they save a hell of a lot of time that can then be invested in things that'll have a more material improvement for the end user.

Re: Bootstrap 5 will remove jQuery as a dependency

#168
post #70

Earlier quoted context omitted.

> As one of the commenters pointed out, a lot of stuff was copied from jQuery to make it work. > In other words, this entire effort seems of dubious benefit to me. You made other points, but I wanted to focus on this one. Yes, there's a few remaining bits that don't have standards. But you can do so much with querySelector, classlist.toggle(), lastElementChild, scrollIntoView, insertAdjacentHTML - literally every Jav…

> Side benefit: also no weird $(thing)[0] when you need to use a DOM API, like HTML5 validity or whatever. But looping over querySelectorAll() is painful. I'm not really a frontend dev, so perhaps I'm doing it wrong, but this is the "easier" way I found when I was writing an app a few weeks ago (in TypeScript): // Get Array of HTMLElements from querySelectorAll(). let queryAll = (q: string): HTMLElement[] => { let no…

    return Array.from(document.querySelectorAll(q));

Re: Bootstrap 5 will remove jQuery as a dependency

#169
post #70

Earlier quoted context omitted.

> As one of the commenters pointed out, a lot of stuff was copied from jQuery to make it work. > In other words, this entire effort seems of dubious benefit to me. You made other points, but I wanted to focus on this one. Yes, there's a few remaining bits that don't have standards. But you can do so much with querySelector, classlist.toggle(), lastElementChild, scrollIntoView, insertAdjacentHTML - literally every Jav…

> Side benefit: also no weird $(thing)[0] when you need to use a DOM API, like HTML5 validity or whatever. But looping over querySelectorAll() is painful. I'm not really a frontend dev, so perhaps I'm doing it wrong, but this is the "easier" way I found when I was writing an app a few weeks ago (in TypeScript): // Get Array of HTMLElements from querySelectorAll(). let queryAll = (q: string): HTMLElement[] => { let no…

  let queryAll = (q: string): HTMLElement[] => {
    let nodes = document.querySelectorAll(q);
    return Array.from(nodes).filter(node => (node instanceof HTMLElement)) as HTMLElement[];
  }
Will do the same. Note that `Array.from()` is a relatively new method, that you will need to polyfill if you wish to support internet explorer, but `Array.prototype.slice.call()` serves the same purpose and can be used in older browsers.

Re: Bootstrap 5 will remove jQuery as a dependency

#170
post #126
post #82

Earlier quoted context omitted.

Only part of the world is moving to css-in-js. I won't be on the boat leaving for that destination.

CSS in JS isn't CSS. It's just SS. It ignores the best part of the language; the cascade.

1) it doesnt ignore it

2) anyone claiming not to have a single `style=""` attribute (which is almost as specific and 1000x less maintainable) in their code is lying

Post reply on HN