3 ms·
Jquery still solves a lot of the problems and saying bloat about is nonsense. Nowadays everyone embeds mega of worth libraries to build a damn blog. But using
by angry-hacker 10y ago
Jquery still solves a lot of the problems and saying bloat about is nonsense.
Nowadays everyone embeds mega of worth libraries to build a damn blog. But using jquery to do some basic Dom changes, Ajax and other simple stuff (which you would write you own helper functions for anyway) is bloat.
Long live jquery.
- verbify 10y agoNot to mention the syntax is nicer. Compare the wordy: > document.getElementById('myid'); to > $('#myid'); I feel the same way about underscore. Regardless of the helper functions, readability goes up.
- seangrogg 10y agoSo, jQuery instead of just... function $(sel) { switch (sel[0]) { case '#': return document.getElementById(sel.slice(1)); case '.': return document.getElementsByClassName(sel.slice(1)); default: return document.getElementsByTagName(sel.slice(0)); } } I mean... "readability".
- angry-hacker 10y agoAnd in the end, you add 10 of those selectors. Then you create a small library so they are all at the same place and handy. Then few fixes to support that one browser in that case. And in the end you have jquery.
- seangrogg 10y agoI think you're forgetting additional HTTP functionality, rudimentary animations, additional wrappers around existing JavaScript representation of DOM nodes, and a variety of other things that you'll never realistically used but thrown into all your applications for posterity. Because in the end, you had jQuery.
- angry-hacker 10y agoWith http2 the additional request is not a problem. If you don't use jquery, you don't care about old browsers/OS not supporting them either. Also, cdn+caching of the library.
- seangrogg 10y agoBytes are bytes are bytes, http/2 or no. It's far less intensive to polyfill what features I actually am using than sending down all of jQuery, and that can still be minified, gzipped, cached, delivered via CDN, and cache-controlled and/or placed in the application cache via service workers (where available). But I can understand that it's less about the user experience and more about the developer experience nowadays.
- tylerlh 10y agoWith that you would end up with something more like Sizzle[0], not necessarily jQuery. [0] https://sizzlejs.com/ https://sizzlejs.com/
- hex13 10y agoin HTML5 would be sufficient: const $ = document.querySelectorAll.bind(document); (but it would be only pseudo jQuery, the way you can have pseudo React just by using functions and ES6 template strings https://jsfiddle.net/vug86rn0/ https://jsfiddle.net/vug86rn0/ )
- fetbaffe 10y agovar $ = document.querySelectorAll.bind(document); $('#myid');