Skip to main content
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Claude Englebert
Ben Nadel at Scotch On The Rock (SOTR) 2010 (London) with: Claude Englebert

jQuery Reference Guide By PACKT Publishing

By
Published in , Comments (10)

I just finished reading the jQuery Reference Guide: A Comprehensive Exploration of the Popular JavaScript Library, by PACKT publishing, co-authored by Jonathan Chaffer and Karl Swedberg. This book is fantastic! It's a bit strange to review a reference manual because it's really just listing out all the features of the API. But, it's the way in which this is done that makes this reference guide so effective. Almost every single method and selector is explained in depth with both clear, concise code snippets as well as rendered displays when necessary. Not only did I come away with a wonderful understanding of jQuery API, I also learned more about JavaScript in general (specifically event handling and the XMLHTTPRequest object).


 
 
 

 
jQuery Reference Guide By PACKT Publishing - Jonathan Chaffer And Karl Swedberg  
 
 
 

EDIT: Sorry I didn't mention this before, but the website that accompanies this book, http://book.learningjquery.com/ is an excellent resource for hands-on understanding of the code in the book. It also fills in some of the knowledge gaps that I discuss below.

This book is a must have for anyone that is serious about effectively leveraging jQuery in their applications. While the API is very simple, it is also extremely robust and powerful. Even when you think you have a good grasp on how things work, reading a manual like this points out all the little facets that you didn't know existed; whether it be optional method arguments or miscellaneous selectors, you probably aren't writing code as effectively as you could be, and you can't do that until you have at least a general understanding of all the features that jQuery makes available.

One of the great things that this book does, which is rare for an API-style book, is to explain, when possible, what the jQuery API is using behind the scenes to access and traverse the document object model. For instance, it explains that the getElementsByTagName() is used to filter tag-based selectors and that getElementById() is used to filter id-based selectors. While this might not seem important to understand, and after all, the whole point of encapsulation is so that you don't NEED to understand, it can become very useful in terms of optimization. For example, $( "#pagetitle" ) is going to be faster than $( "h1#pagetitle" ) since it can use the direct ID access rather than tag-based filtering. Also, $( "h2.title" ) is going to be faster than $( ".title" ) since it can use the tag-based filtering and not have to iterate over every DOM element looking for a particular class.

In addition to covering the full jQuery API, this book also contains a cursory exploration of the architecture and authoring of custom plug-ins. While the book thoroughly covers basic plug-in authoring, I wish that they had covered some more complex stuff; but, at the same time I think that that probably would be more appropriate for a plug-in based book rather than a general reference manual such as this one.

After discussing plug-in architecture, this book also explores two popular jQuery plug-ins: Dimensions and Form. The dimensions plug-in enhances the built-in height() and width() object methods that already exist. It also introduces a host of other methods that allow developers to find the dimensions and position of elements with the conditional incorporation of various CSS box model properties. The Form plug-in contains many methods that make it super easy to submit a form using AJAX, including many utility methods that assist in the serialization and accessing of form data.

The book does a good job of explaining how the individual Dimensions methods work, especially the height and width related calculations. The position related methods, while explained in depth, left me confused; the demo HTML used in the chapter is explicitly incomplete and this makes it difficult to visualize where the calculated numbers are coming from. It wasn't until I went to the demo site (http://book.learningjquery.com) that the calculations became clear. Even then, however, you can see that as much as the jQuery plug-ins try to encapsulate the cross-browser issues, there are still problems to be found. For example, calling $('div.dim-outer').offset() returned a LEFT value of 580 in FireFox 2.0 and a LEFT value of 1116 in Internet Explorer 6.0.

The book does a good job of explaining how the individual Form plug-in methods work. And, while I am not one who does a lot of AJAX form submission, I can see how using this plug-in would make that a painless process. Regardless, this plug-in also contains some great utility functions that allow you to grab form data at any given time. This can be useful for partial form updates such as the common two-selected-related scenario. My one gripe with this section is the same issue I have throughout the reference manual: callback arguments are not explained very well. With the form submission process, there are two callbacks available - beforeSubmit and success. Both methods are explained in natural language terms, but only the beforeSubmit method gets a code sample explanation (seven pages after it was explained in english). I don't know about you, but seeing a snippet of code is 10 times more clear than the equivalent natural language description.

This is very nit-picky, but as much as I loved this book, there were a few things that were not perfect; while the majority of the selectors are thoroughly explained, the big exception is the Form selectors. I have gone over this section several times and I just can't quite figure out what it means. The big problem is that unlike the rest of the book, the form selectors have no code samples; it's just be a list of input types, but not listed in any meaningful way. This section feels like an afterthought in the book.

I also felt that some of the callback methods could have been better explained. Most of the jQuery callback methods have arguments passed to them, but unless they were used in the examples, they were not defined as part of the callback function definition. I would rather have seen every argument explicitly defined, whether it was used or not, so that we as developers could see what our options were.

The only other problem with this book is that the jQuery technology is evolving so fast that the most recent release of jQuery (v.1.2.1 at the time of this writing) already has things that are not covered in this book. Not only that, a few of the things that are covered in this book, namely the XPath style selectors, are no longer supported by the core jQuery API (but rather though small plug-ins).

Overall though, this book is excellent and I highly recommend it to all web developers, especially those not yet using jQuery so that they can see just how amazing this Javascript library really is. Not only will it teach you all about jQuery, it will probably instill a better understanding of Javascript in general. From me, it gets two thumbs us.

Reader Comments

50 Comments

Wow, Ben, great review. And thanks. Hopefully you've posted it to Amazon as well (just checked and it's not there, but maybe it's in the process of being approved). Saw John Farrar's review there. Go CF community! :-)

15,811 Comments

@Charlie,

Thanks! Yeah, I posted it to Amazon as well (my first every Amazon review) and apparently they have a 1-2 day approval time line. Hopefully should be up early this week.

57 Comments

You should post this to the jQuery mailing list (unless Rey beats you to it!)

I'm sure the book authors would appreciate the feedback.

17 Comments

Hey Ben and other jQuery'ers,

Another fantastic book, while not specifically related to jQuery, is jQuery creator John Resig's book: Pro Javascript Techniques. Reading this book shored up many of the gaps in my understanding of JS, and John's enthusiasm for the subject is exemplified throughout, which makes the book that much more enjoyable. As evidenced by the jQuery library itself, John's understanding of JS is highly advanced, and his explanations of the various concepts are excellent.

10 Comments

@ Josh Nathanson

Could you throw more light on John's book. I'd really love to hear what you think about it. I had a choice of either buying John's book or Javascript: The Definitive Guide. I ended up purchasing Javascript: The Definitive Guide, cause I wanted an extensive reference.

1 Comments

I am trying to learn Jquery now. I am an ASP.net developer and know Ajax. Jquery makes everything much simpler and required less resources from my database. Thanks for the review. I will try to get a copy soon.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel