Simon on jQuery

Simon Willison—soon to be a fellow Brighton resident—has posted a lengthy overview of the jQuery library aimed specifically at JavaScript coders (as opposed to designers). Simon wasn’t initially all that impressed by jQuery:

When jQuery came out back in January 2006, my first impression was that it was a cute hack… I wrote jQuery off as a passing fad.

Like Simon, I’ve been very wary of jQuery and just about every other JavaScript library out there. But I’ve started kicking its tyres on a recent project I’ve been working on. For the most part, I’m fairly impressed. The selectors—based on CSS selectors—really do make life easier. I like the simple philosophy of jQuery:

Find stuff and do stuff to it.

This combination of selectors and events covers an awful lot of typical JavaScript development. That said, I have found some issues when I’ve delved into the effects: sliding, fading and all that stuff. The problems generally aren’t actually JavaScript problems: because the effects work on altering CSS properties, it can be hard to predict how the effects will interact existing style declarations.

Mostly I’ve found that jQuery is neither inherently good or inherently bad: it’s neutral. I suspect that’s true of most JavaScript libraries. It’s still up to the developer to use best practices and make things unobtrusive.

No library is a magic bullet and no library can compensate for a lack of basic JavaScript knowledge but the “play nice” philosophy of jQuery means that, if it’s handled correctly, it can make life easier for the developer without making life harder for the end user.

Posted by Jeremy on Wednesday, August 15th, 2007 at 10:47pm


Likewise, I’ve been impressed with jQuery on a recent project. But it doesn’t belay you from your responsibilities to understand what it’s doing. We had a complaint from one of our testers that a particular page was causing IE to emit a dialog box asking if it could kill the script that was taking too long. Naturally, 2Mb of HTML will slow down all JavaScript. But in this case, it was immediately clear that the selectors weren’t specific enough and would go through the entire page. No wonder IE was complaining. A quick change from $(‘.foo’) to $(‘#someid .foo’) worked wonders. But used correctly, jQuery is a marvellous aid. I switched a little way into the project and got a significant reduction in the amount of code that I had written. Conciseness is an asset.

Incidentally, the project is all based around XML and XSLT. I came up with a somewhat sneaky piece of XSLT that strips out all inline JavaScript and inline CSS. Now the developers can try to put it in there, but it won’t show up in the page. :-)

# Posted by Dominic Mitchell on Thursday, August 16th, 2007 at 12:32am

After using it for just a few hours, I quickly found that it is so much more than fancy animating effects. I’ve now replaced all of my own personal javascript code in this project with JQuery. If you find yourself programming javascript occasionally, I highly recommend you look into using JQuery. Not only is it a pleasure to use, but their documentation is fantastic.

# Posted by Tomek on Thursday, August 16th, 2007 at 1:30am

I’ve only looked at jQuery and FORK, but I have used Prototype extensively, including on production sites. My feeling is that if you’re writing a lot of JavaScript and you’re not using one of these libraries, you’re wasting your time (and, by extension, your client’s money!).

It is important to be aware of possible "gotchas", but overall a thoughtful library can make your life a whole lot easier!

# Posted by Andrew Hedges on Thursday, August 16th, 2007 at 10:33am

I have been replacing much of the Javascript used in all of my sites with jQuery code. It is prettier, easier to understand, and just plain works better. Initially I was not too interested in jQuery. I personally used Prototype and Scriptaculous but I never actually understood the code i was writing. I never studied Javascript so in general, JS is a bit intimidating to me. I basically took samples of code from other sites and stuck them into my own. Now, with jQuery, I can write my own code and actually know what i am doing. I also recommend the Learning jQuery book from pact publishing - it makes a world of a difference.

# Posted by bryan on Thursday, August 16th, 2007 at 2:55pm

I’m a pretty big Prototype fan, and its what we use in the company I work for, so I’ve never taken the time to actually sit down with jQuery. From the looks of it, they’re both pretty much the same and you’ll have fanboys in either camp preferring one over the other.

From the looks of it, jQuery looks much more simplified than Prototype, but in a way that almost scares me. But there’s nothing in jQuery that would convince me to make a personal switch. I’d love for someone to alert me (and maybe the rest of the Prototype community) that would make a pretty good argument.

Can anyone comment on personal experience of using both jQuery and Prototype in a production environment. Pros? Cons? Pretty much the same, either way?

A good read, Jeremy.

# Posted by Eric Fields on Thursday, August 16th, 2007 at 3:44pm

Once I felt confident with my abilities to write scripts from scratch, I began to try out libraries. I found jQuery to be the best swiss army knife for me (and the organization I work for). I can whip up readable and reusable scripts with jQuery, yet I have a hard time doing the same when I write from scratch. The key when you work with other developers is to make code they can understand. It is easier to understand 40 lines of jQuery rather than 100 lines of scripting from scratch.

P.S. Your validation script found my email address to be invalid, so I had to use my gmail address.

# Posted by Marc on Thursday, August 16th, 2007 at 3:47pm

Thanks for the review Jeremy. Since I’ve read your book I’ve looked to your work as an example of "best practice" for scripting. I just found out about jQuery a few weeks ago, and I’ve been a bit skeptical about giving it a try. You confirmed pretty much what I thought after browsing a few pages and examples on the jQuery site.

I’d be interested in further write-ups and reviews of jQuery if you happen to work more with it.

# Posted by Evan on Thursday, August 16th, 2007 at 8:46pm

I’ve used jQuery in my project and found it very useful when it comes to adding interactivity to the page. Saved me hours of work if I had to code from scratch. I would like to share JQuery Portlets ( if you haven’t used it before.

# Posted by Zeb on Sunday, September 2nd, 2007 at 8:07pm

I have a lot of Javascript code used in my projects. I have found how it’s easy to replace it almost all with jQuery code. And now it more easier and even works more better than before. Initially I tried to use Prototype, but found it to complex fo me. Now with jQuery I rewrited 90% of all code in all new projects and actually saved hundreds hours of hard work.

# Posted by Kevin Mailer on Sunday, September 2nd, 2007 at 10:06pm

Yes, jQuery is great because of its simplicity and power. I have also replaced some of my own scripting with jQuery. But the best thing about it is its implementation of unobtrusive scripting. Most other frameworks don’t do nearly as well when it comes to progressive enhancement.

# Posted by Dennis on Wednesday, September 5th, 2007 at 8:16pm

Have you had a look at Mootools? If you have problems with jQuery in regards to JavaScript effects it could put an end to your problems. Mootools has taken a lot from other frameworks such as Prototype, builds on them and also adds a lot of new features. You can check the effects out here:

# Posted by David Hopkins on Friday, September 14th, 2007 at 11:41am

Sorry. Comments are closed.

August 2007

Recommended Reading

XML Subscribe

Grab the RSS feed for this blog.

JavaScript API

Grab the RSS feed of comments for this entry.