News for hackers. Stuff that matters.
Re:JQuery Code Smells by IgorPartola on Thursday January 07, 2010 @12:14PM (#1037427)
> Prefixxing all jQuery objects with $

So don't do it. It's not required.

> Concatenating a bunch of things together to make a selector

This is semi-valid and using the jQuery.filter() function helps a bit. Overall though, it's not a huge problem, IMHO. Just put together the selector incrementally. Likely you need bits of that selector elsewhere anyways.

> Going over the top with chaining

I've written some complex code using jQuery and none of it had a chain as long as your example. Still don't see how this is jQuery's fault.

> Not caching collections

Then cache them. How is jQuery preventing you from doing this?

> HTML

This is just runs faster. When performance is critical, I find it acceptable to do this.

Re:JQuery Code Smells by jcl on Thursday January 07, 2010 @12:52PM (#1037537)
The article is not complaining about jQuery. A "code smell" is something in the code that is not necessarily bad in itself, but may indicate that the code's author is inexperienced or unskilled. Such code may contain subtler errors.

The author is pointing out coding practices that cause him to suspect that others' jQuery code may not be very good.

Re:JQuery Code Smells by JP1990 on Thursday January 07, 2010 @12:44PM (#1037513)
You've misunderstood the intent of the post. It's mostly my fault -- I shouldn't have named it "jQuery code smells". The point of the post was to list jQuery code snippets that exhibit "code smells", -- you seem to be under the impression that I think that jQuery itself, smells. And that couldn't be further from the truth.
Re:JQuery Code Smells by RyanMcGreal on Thursday January 07, 2010 @01:59PM (#1037744)
> you seem to be under the impression that I think that jQuery itself, smells.

That's exactly what I thought ... until I read the article. Your intent seems pretty clear to me; but if a lot of people are misunderstanding you, that's a good sign you need to change the message to address the widespread confusion.

Re:JQuery Code Smells by IgorPartola on Thursday January 07, 2010 @01:21PM (#1037639)
Actually, I was under the impression that you were putting the blame for sub-par code on jQuery, not on the people using it. I agree that most of these practices a at least a bit odd, but thankfully jQuery does not force any of them upon you.
Re:JQuery Code Smells by aasarava on Thursday January 07, 2010 @01:11PM (#1037604)
Simple editorial fix: Add quotes to the title to clarify that you're referring to the noun, "jQuery 'Code Smells'", rather than making the statement that "jQuery Code is Smelly".
Re:JQuery Code Smells by markkanof on Thursday January 07, 2010 @12:55PM (#1037550)
Agreed with regard to the HTML point. There are a bunch of things that can be done with string concatenation that can improve performance significantly. It may not be pretty to have HTML strings embedded in the JavaScript, but sometimes it is necessary to achieve acceptable performance.
Re:JQuery Code Smells by axod on Thursday January 07, 2010 @01:00PM (#1037567)

  1. Use a slow js library framework abstraction layer! yay!
  2. Speed it back up a bit by using ugly messes of html strings