4 ms·
Agreed. I've seen numerous times developers include jquery just to make a simple request that can be replaced by XMLHttpRequest. Ref: http://youmightnotneedjqu
by kroboker 7y ago
Agreed. I've seen numerous times developers include jquery just to make a simple request that can be replaced by XMLHttpRequest.
Ref: http://youmightnotneedjquery.com http://youmightnotneedjquery.com
- yyyk 7y agoThat site looks more like an secret advert for jQuery than any attempt to remove it. Maybe a comparison using more modern browsers would be more convincing...
- Carpetsmoker 7y agoA friend of mine created a spoof to make exactly this point: https://youmightneedjquery.com/ https://youmightneedjquery.com/
- cm2187 7y agoWhat strikes me with this youmightnotneedjquery is that half of the examples take many more lines of code than a single jquery instruction.
- archie2 7y agoEspecially when it comes to browser support...why would I not use JQuery in those cases? I still use JQuery to this day, but probably because I don't really rely on JS in my applications that much. Unless you're building an "app" from the get-go, it's still my default choice.
- Silhouette 7y agoEven the information on that page is quite dated now, as IE becomes less relevant. As others have said, some of its examples were ironically pretty good adverts for jQuery at the time it was first published. However, you hardly ever need to use an XMLHttpRequest any more, and the native Fetch API is already as simple as jQuery's interface for most day-to-day tasks. The only major browser that doesn't support Fetch is IE, and if you still need to support IE for now, you might be better off with a simple polyfill for the standard Fetch API rather than coding around jQuery. Similarly, there is no need for monstrosities like calling Array.prototype.forEach.call on a NodeList returned by querySelectorAll instead of jQuery's $.each any more. Again, everything except IE supports forEach directly on a NodeList, and if you still need IE support, you can use a simple polyfill. If you need a real array to work with, an ES6 spread operator will build this for you with something like [...document.querySelectorAll('.someClass')] since the NodeList is iterable these days too.