3 ms·
I think he has a few points. If you disagree with some of his points, argue why. FWIW, I also view js libraries with skepticism. I'm not convinced they're a ne
by axod 17y ago
I think he has a few points. If you disagree with some of his points, argue why.
FWIW, I also view js libraries with skepticism. I'm not convinced they're a net gain for the web. (I'm talking about general purpose libs. UI libs obviously provide value).
There's this misconception that working with the DOM is hard, or can't be done in a cross browser way without bolting on a big js lib.
Even something as simple as a closure is routinely packaged up in a js lib as .bind() why??? Add to that the fact they usually do silly things like convert arguments to an Array etc just to slow you down some more.
When you see news stories like "js lib X latest release is 5 times as fast as previous version!" You should not think 'wow that's great'. You should think 'jesus christ how could they have written it so slow to start with? How do I know they've written it properly this time? Time to stop using js lib X'
- mattmanser 17y agoThis just sounds like you haven't used jQuery yet. Then you'll know why.
- axod 17y agoI've seen jQuery code. It doesn't do anything particularly useful for me. It solves problems I don't have. I don't need to lookup elements in the dom, because I put them there. I already know where they are. I don't need a slow .bind() method - I know how to write closures. Look at one of the top news items - jQuery plugin 'behavior'. It just doesn't make any sense. Look at some of the source code. For example .addClass(). It's the most general you could imagine - can take a list of classes, or a function. Yet I'm betting most of the time it's being called with a single class to add. There's a lot of wasted checks and effort in there. It's checking the type, it's splitting the string on " ", it's checking to see the class isn't already listed etc etc Also everything is assuming it's operating on a list of elements - cue wasteful for loops when they're not needed. So, when you do the seemingly simple $('#myelement').addClass("foo"); it'll be cycling through the array of elements of length 1, splitting 'foo' on spaces, checking if 'foo' is a function, etc etc etc etc Those are precious wasted cycles. And for what? so you can write: $('#myelement').addClass("foo"); instead of: // I already have a js ref to myElement thanks, // and know myElement doesn't already have 'foo' in className myElement.className+=" foo"; </rant>
- ra 17y agoYou make some fair points. I believe jQuery's strength is that it allows you to accomplish things neatly without needing to know the sins and virtues of Javascript.... The point is that there are plenty of both.