Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This just sounds like you haven't used jQuery yet. Then you'll know why.


I'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>


You 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: