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 gene…
You can "eat the cake and have it too" with something like this: http://microjs.com/ Basically you import everything you need and only what you need. Need extend? No prob: 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…
You Don't Need JQuery
151–160 of 201 posts
Re: You Don't Need JQuery
#152Re: You Don't Need JQuery
#153Earlier quoted context omitted.
make building your site more complicated than compiling an entire Linux distribution from source http://browserify.org/ Browserify is not at all complicated. spend days choosing between a bunch of almost identical micro-libraries for every little thing you need to do Just search npm and pick the one that is being used the most. lock yourself into a proprietary framework that will be considered legacy code as soon as…
So, basically, you end up rewriting the glue code and plumbing, keeping track of twenty-eight security bulletins instead of one, and hoping that someone doesn't get a zero-day in a less used library that doesn't has much security attention paid to it. And that's fine, if writing a framework per project is something you have time for. But make no mistake -- you're writing a framework.
I'm not sure what you mean. Can you give an example?
keeping track of twenty-eight security bulletins instead of one, and hoping that someone doesn't get a zero-day in a less used library that doesn't has much security attention paid to it
System administrators, developers of pretty much any language, and even chip designers have to deal with the issues related to code that wasn't written in-house. We live in a modular world.
But make no mistake -- you're writing a framework.
React and the Common JS module system are enough of a framework especially when compared to jQuery.
I'm getting the feeling that most people on this forum don't really know nor care how these tools work and are mainly interested in making snarky jabs.
Your criticism isn't digging deep enough in to these tools to even make much sense.
Re: You Don't Need JQuery
#154You can basically sum up this entire rather ridiculous site with "Yes, you don't need jQuery, you can just use the built-in methods, but using jQuery is generally more pleasant, more consistent, and involves less typing". One particularly egregious example from the site: $('#foo').removeClass('bold'); vs. document.getElementById('foo').className = document.getElementById('foo').className.replace(/^bold$/, ''); The au…
Actually since forever, you don't need to use document.getElementById("x") in any case. You just by putting the id to the element, it is already available to you referencing it by such id. So this: document.getElementById('foo').className = document.getElementById('foo').className.replace(/^bold$/, ''); Can become to this: foo.classList.remove("x"); And is miles away more performant than slow jQuery.
Re: You Don't Need JQuery
#155I disagree, jQuery is awesome, even for seasoned web developers. Of course you don't need it, but it makes life a lot easier when working with XHR, events, selectors, etc. If you're worried about dependencies, you could just compile your released library with the Google Closure compile, and strip out everything you don't use. You could even set up a pipeline to produce two releases: one that has bits of jQuery embedd…
It's better to just use one of the jquery versions hosted on the google developer cdn: https://developers.google.com/speed/libraries/devguide If you link to a popular jquery version, I bet the odds of the user already having the library cached is approaching 95%+ so your dependency is essentially free as no requests will be made in that case.
http://www.i-technology.net/2013/11/the-myth-of-cdn.html
more data: http://www.stevesouders.com/blog/2013/03/18/http-archive-jqu...
Re: You Don't Need JQuery
#156Earlier quoted context omitted.
.classlist() [1] is coming [2]. It'll allow you to do: document.getElementById('foo').classList.remove("bold"); Sure, it's still more verbose. But a lot of what jQuery does is slowly being obsoleted by better native javascript apis. [1] https://developer.mozilla.org/en-US/docs/Web/API/Element.cla... [2] http://caniuse.com/#feat=classlist
So when those new native api functions arrive, jQuery will start using them and gain some performance boost (using native vs. custom js code) while at the same time remaining backwards compatible (by doing feature detection). No one wants to write their own feature detection code so this whole page about using native apis is instead of jQuery is ridiculous. If the point of that website was to educate people on the ap…
Re: You Don't Need JQuery
#157Earlier quoted context omitted.
This may seem anecdotal, but I can tell you from writing a lot of non-jQueryified code that with modern browsers, applying classes to dozens of elements dynamically can be an anti-pattern. 99% of the time, when doing something which previously would have required that, I can use a single class on a parent element.
Not if you're in an environment (like mobile) where you want to reduce repaint.
Re: You Don't Need JQuery
#158 "This is your reminder that the DOM is actually a giant,
mutable, global variable in the middle of your program.
Act accordingly." –Marco Rogers (@polotek)
https://twitter.com/polotek/status/543590973846999040