Thursday, November 20, 2008

Book Review: jQuery in Action

jQuery in Action by Bear Bibeault and Yehuda Katz is an excellent book for learning the jQuery JavaScript library. In my opinion the book is suitable for beginners as well as advanced developers that like to explore jQuery. It is also a good reference book as it describes all the essential functionality offered by jQuery in a nicely structured manner.

I belong to the category of developers that used Prototype in the past. The funny thing is though that both libraries offer almost identical sets of functionality. You may ask why did I decide to go with jQuery?

I like its innovative way of querying for page elements and to iterated over them, allowing you to often accomplish multiple tasks with just one line of code. jQuery in Action starts out explaining those core concepts of jQuery in the first 3 chapters of the book - allowing to query for page elements using the CSS syntax, how to manipulate page elements as well as how to work with collections of elements. The book does a very good job explaining those aspects of jQuery combined with many useful examples.

What also drove me to jQuery was the fact that it has a plug-in mechanism that allows you to either use additional third party add-ons or to write your own plug-ins by still adhering to the spirit of jQuery.

In that regard it is also worth mentioning that the jQuery website is "really nice" with a ton of documentation and also providing a plugin-repository, something Prototype is lacking. Thus, for the majority of your JavaScript needs, there is now a one-stop place to get it all.

Unfortunately, the authors do not provide a comparison between both wildly popular javascript libraries Prototype and jQuery even though Bear Bibeault has been a coauthor of Prototype and Scriptaculous in Action. It would have been nice if chapter 1.1 Why jQuery detailed some pros and cons in that respect.

Generally, throughout the book, the authors encourage certain valuable patterns you should follow to write good unobtrusive JavaScript code using jQuery. I particularly like that aspect of the book as it shows you efficiently how to separate page markup from JavaScript code.

In that regard it would have been nice, though, if the authors had mentioned YSlow as another tool to analyze you page markup, which includes the recommendation to place JavaScript at the bottom of your page rather then on the top, if possible.

Anyway, there shouldn't be any need to declared the onclick attributed on page elements directly any longer. It all can be separated using JavaScript events which is well described in the book.

Speaking of handling JavaScript events, I think the authors should have further mentioned the concept of event delegation. Instead, they describe how to use the Live Query plugin in order to solve a similar issue. After reading the respective chapter, I was going to further dive into Live Query but a fellow blogger pointed out NOT to use Live Query as "it is very performance heavy" but rather to use event delegation.

I guess this is a drawback writing a book about a subject that is evolving with the speed of light.

Nevertheless, despite all my critical remarks, I think that jQuery in Action is an excellent book that will help you learn and understand jQuery. I certainly enjoyed reading the book.

3 comments:

Anonymous said...

jQuery website is "really nice" with a ton of documentation and also providing a plugin-repository, something Prototype is lacking.
The Scripteka extension library for Prototype is similar in nature to jQuery's plugin-repositiory.

Gunnar Hillert said...

Thanks for pointing out Scripteka. Looks very slick indeed. But I was unaware of that site - and a link to the Scripteka site is not easily found on the Prototype site.

Tracy said...
This comment has been removed by a blog administrator.