6 ms·
Every time I try to build something without jQuery, I regret it. Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not bec
by random28345 12y ago
Every time I try to build something without jQuery, I regret it.
Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not because of DOM manipulation, as long as you're willing to sacrifice simplicity and readability, you can build iterative loops to modify a collection of HTML elements.
No, it's the unexpected things that cause me pain. Want to use event handlers on dynamically generated DOM objects? Write your own event bubbling library. Want to create custom events/handlers? Ditto. Promises, .serialize(), .extend(), etc. might all be simple to write your own version, but when you realize you've reimplemented 50% of jQuery to avoid using jQuery, you feel like an idiot. [Source: I do this every 3 years]
Life is too short to not use jQuery.
- sfeng 12y agoThere are other libraries though which provide (IMHO better) implementations of each of those things. jQuery has been around for ten years and has to remain backwards compatible. It's just not possible for it to be the best implementation of Promises, or AJAX or any of the other individual things it does. Real bundling with tools like Browserify is making it more and more feasible to use single-purpose libraries instead of monolithic ones like jQuery.
- random28345 12y ago> There are other libraries though which provide (IMHO better) implementations of each of those things. jQuery has been around for ten years and has to remain backwards compatible. It's just not possible for it to be the best implementation of Promises, or AJAX or any of the other individual things it does. I agree with all those things. jQuery is the lowest common denominator. It's the best at nothing, bloated with support for Palm Pilot browsers and Safari 1.0, and doesn't have all the cool grunt/gulp/amd/broccoli/cucumber/jsx/fotm neologisms. If I'm building a new, long-term project, I'm going to evaluate all the options, and craft the best possible technology stack for my new app. But sometimes worse is better. Like a smooth pebble pulled out of a stream, it's taken a long journey and had most of the rough edges rubbed off. It's already in your browser cache from 4 different CDNs. Someone else can pick it up and support it easily. And that's what often makes it the best choice, when you want to avoid bikeshedding over what the hottest new thing is, and just make a webpage. jQuery may not be the best technology, but it's a sane default.
- bombtrack 12y agoI'm sure you're aware of this, but for others who may not know: the 2.x versions of jQuery dropped support for old browsers (IE 6, 7, 8) to reduce size (12% smaller) and complexity necessitated by being so backwards-compatible [0]. Thankfully we only support IE9+ where I work, so I grab the latest 2.x version these days. [0] - http://blog.jquery.com/2013/04/18/jquery-2-0-released/ http://blog.jquery.com/2013/04/18/jquery-2-0-released/
- wvenable 12y agoThe thing is there's always other libraries that provide better implementations of things. Likely the instant you pick one, there will be something "better". jQuery has the benefit of being as much of a standard library for the web as anything else. Often it's not worth the time and effort to hunt down the absolute perfect combination of libraries to accomplish the same thing.
- Youpinadi 12y agoAgreed 1000%
- NDizzle 12y agoYep. Use the built in browser methods? For which browser?!? All of them? I have to support some enterprise guys on IE8, sometimes I'm lucky to have them on IE9. Life isn't always a hipster website where people can get lunch delivered on their phone or whatever. Things like jQuery are fine.
- pjmlp 12y agoFully agree with you, it is worse actually as even between versions of a specific browser, behaviors change.
- williamcotton 12y agoLife is definitely too short to not be using npm, browserify and React! https://www.npmjs.com/package/browserify https://www.npmjs.com/package/browserify https://www.npmjs.com/package/react https://www.npmjs.com/package/react And then use just what modules you need. All the functionality of jQuery has already been ported to various modules. https://www.npmjs.com/package/extend https://www.npmjs.com/package/extend https://www.npmjs.com/package/promise https://www.npmjs.com/package/promise https://www.npmjs.com/package/serialize-form https://www.npmjs.com/package/serialize-form
- random28345 12y ago> Life is definitely too short to not be using npm, browserify and React! These are all cool things, but sometimes you want to simply make a web page without setting up node and npm and all that jazz. Think of it this way... jQuery is like getting a subset of the most common functions you get by using in browserify, but without requiring a build step!
- klibertp 12y ago> sometimes you want to simply make a web page without setting up node and npm and all that jazz No, absolutely impossible. That would mean I'd have to actually write JavaScript instead of LiveScript and that would be unbearable... ;) On a more serious note: yes, node is a bit of an overhead. It may be too much for very simple, one-off projects, but it starts making sense as soon as the project becomes even a little bit more complex.
- williamcotton 12y agoThis is about more than just a build process. jQuery's imperative DOM manipulation is a horrible way to manage state compared to React. These tools aren't just "cool things". They were designed to solve really pressing issues related to managing complexity in front-end web applications by eliminating global state in both the DOM or the JS runtime environment. They tend towards a more declarative and functional approach to system design. A build process that integrates with a versioned package manager is fantastic.
- Pxtl 12y agoYeah, the problem with jQuery is all that other stuff that nobody uses and backwards compatibility with browsers nobody supports. A "lite" jQuery with the same familiar API but a stripped-down featureset for higher performance and smaller size would be nice.
- K-Wall 12y agoZepto might be what you are looking for. http://zeptojs.com/ http://zeptojs.com/
- abritishguy 12y agoJust use the CDN copy of jquery and it will be cached in the users browser already since so many websites already use it.
- LocalPCGuy 12y agoNot really, the cache-hit benefit is a myth. Too many CDNs, too many versions of jQuery in use, cache's too small... So ..using jQuery via a CDN, depending on which you use you have a 1 in 119, or 1 in 833 chance of the user having a cached copy. http://www.i-technology.net/2013/11/the-myth-of-cdn.html http://www.i-technology.net/2013/11/the-myth-of-cdn.html more data: http://www.stevesouders.com/blog/2013/03/18/http-archive-jquery/ http://www.stevesouders.com/blog/2013/03/18/http-archive-jqu... There are valid reasons to use a CDN (get the scripts closer to the end user, offload the data transfer costs to the CDN provider, etc) but it isn't due to the potential for a cache hit.
- chdir 12y ago> you have a 1 in 119, or 1 in 833 chance of the user having a cached copy That statistics has assumptions on what's the most popular jQuery versions being used. It would make sense if there was real data to support that.
- dmethvin 12y agoYou're aware of jQuery custom builds? Leave out what you don't use. It's in the README file.
- kaonashi 12y agoReact handles event normalization, fyi.
- klibertp 12y agoYou can "eat the cake and have it too" with something like this: http://microjs.com/ http://microjs.com/ Basically you import everything you need and only what you need. Need extend? No prob: http://microjs.com/#extend http://microjs.com/#extend - just pick one. And with browserify and npm literally everything you need to do to include a library in your project is a single command, so having to include "that many libraries" is not really a problem. I'm a huge fan of having many little libraries instead of a few big ones, and JS - both on the backend and frontend - makes this possible to the bigger extent than most other environments.
- girvo 12y agoSame. Between Micro JS, Vue.js and Browserify, I can craft the perfect tech stack with best-of-breed libraries, and come out with a much smaller, faster, and less janky site at the end of it. Oh, and being CommonJS modules via Browserify makes life pretty great, and my code maintainable and easy to follow!
- icantthinkofone 12y agoI've only used jQuery once, for a client who insisted we use it, and it was the worst experience of my company's life. It only made us use bold on all our documents which proudly states, "No JQuery!".
- _mtr 12y agoSurely you can expand on this story. What made using jQuery so painful?
- mkhalil 12y agoI'll try. My client was mad I was trying to charge him an extra $6000 for the time I spend to get the stuff I write to work across different browsers and asked me to use jQuery instead.
- deleted 12y ago[deleted]
- agumonkey 12y agogreenspuns-tenth-rule.js