A few weeks ago I started to play around with jQuery and I already banged my head against some small gotchas of the framework. But a comment made by Jake Scott opened my eyes:

I recommend you read (if you haven't already) Manning jQuery in Action, its the best book on Javascript ever :)

jquery_logoEven if I might not second the "best book on Javascript ever" part of the comment, I got the book yesterday afternoon and I already read 4 chapter of the book while on the train. I've to say that the books is really well written and easy to understand. And I think I have a crush on jQuery.

I've been using Javascript since a very long time - probably it's one of the first programming language I used when I started developing for the web in '96 - but this framework puts together all the good things from the various programming languages used on the web and everything become so easy to write, and in less time.

You have a bit of CSS, a bit of fluent interfaces (they call it action chaining), you've got also a little feeling of Linq, you have a tiny library (only 15Kb minified and packed) that is very easy to extend with extension methods, and a huge ecosystem of already available plugins. And of course you have Ajax and animation effects.

One of my favorite thing is the way jQuery abstracts the onLoad event of the page:

    alert("I'm loaded, but the images not yet");

The cool thing is that the function defined runs when the DOM tree has been loaded, not, as with the standard onLoad event, when all the element of the page (including all the images) have been loaded. This avoids that a image that takes too long delays the execution of start-up scripts as sometimes happens now when the Lightbox effect doesn't work because some external images or scripts are slow to load.

So, from my first impressions: CSS + Javascript + Linq + fluent API + anonymous methods = jQuery.

OK, there are some gotchas, but which framework doesn't have some?

I'm starting to use it for the UI of the new features in Subtext 2.0 and I might add some goodness to my blog. Let's see if it turns in real love.

Technorati Tag: