Re:How to avoid rewriting your JavaScript application
by verbify on Thursday October 20, 2016 @05:03PM
(#12756141)
Not 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.
Re:How to avoid rewriting your JavaScript application
by seangrogg on Thursday October 20, 2016 @06:43PM
(#12756823)
So, 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".
Re:How to avoid rewriting your JavaScript application
by angry-hacker on Thursday October 20, 2016 @07:16PM
(#12756982)
And 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.
Re:How to avoid rewriting your JavaScript application
by tylerlh on Thursday October 20, 2016 @07:55PM
(#12757178)
With that you would end up with something more like Sizzle[0], not necessarily jQuery.
Re:How to avoid rewriting your JavaScript application
by seangrogg on Thursday October 20, 2016 @08:18PM
(#12757290)
I 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.
Re:How to avoid rewriting your JavaScript application
by angry-hacker on Friday October 21, 2016 @04:40AM
(#12759025)
With 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.
Re:How to avoid rewriting your JavaScript application
by seangrogg on Saturday October 22, 2016 @11:23PM
(#12771720)
Bytes 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.
Re:How to avoid rewriting your JavaScript application
by hex13 on Thursday October 20, 2016 @10:15PM
(#12757717)
in 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/ )
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.