jQuery Reference Guide By PACKT Publishing

Posted October 21, 2007 at 1:38 PM by Ben Nadel

Tags: Javascript / DHTML, Books

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.


You Might Also Be Interested In:



Reader Comments

Oct 21, 2007 at 6:46 PM // reply »
15 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! :-)


Oct 21, 2007 at 7:03 PM // reply »
11,238 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.


Oct 21, 2007 at 10:11 PM // reply »
51 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.


Oct 22, 2007 at 2:18 PM // reply »
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.


Oct 22, 2007 at 3:08 PM // reply »
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.


Feb 11, 2008 at 5:34 AM // reply »
2 Comments

Thanks Josh for the hinting me to John Resig's book - just started reading and until now itīs a fantastic read


Sep 19, 2008 at 10:15 AM // reply »
4 Comments

This has probably saved me a few hours of searching. Thanks!


Sz.
Feb 4, 2009 at 5:55 AM // reply »
1 Comments

What is the best way to learn jQuery? By reading books?


Apr 1, 2009 at 8:30 PM // reply »
1 Comments

Thank you Josh for the hinting me to John Resig's book.

I will buy this book soon to learn that stuff.


EDI
Apr 11, 2009 at 2:23 AM // reply »
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.


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 17, 2013 at 7:42 PM
HashKeyCopier - An AngularJS Utility Class For Merging Cached And Live Data
Ben - thanks so much for posting these Angular articles and findings, they've been a huge help towards learning one of the more 'complex' JavaScript frameworks out there (IMO). I have been using Angu ... read »
May 16, 2013 at 5:01 PM
UPDATE: Parsing CSV Data Files In ColdFusion With csvToArray()
Your code was the closest thing I've found to obtaining some direction for converting ISO fields to values that CF can translate properly. Thank you for posting! ... read »
May 15, 2013 at 10:37 PM
Very Simple Pusher And ColdFusion Powered Chat
hi id making plz easy ... read »
May 15, 2013 at 6:07 PM
Making SOAP Web Service Requests With ColdFusion And CFHTTP
Ben, you once again saved my bacon at work. Thank you, thank you, thank you! ... read »
May 15, 2013 at 4:15 PM
What If All User Interface (UI) Data Came In Reports?
@Josh, Thanks! @Ben, I definitely recommend the David West book "Object Thinking" I've been quoting from. It goes deeply into the philosophy and history of OO programming. His breadth ... read »
May 15, 2013 at 11:36 AM
Ask Ben: Print Part Of A Web Page With jQuery
I found this helpfull when you need to keep (refresh) the original parent page after closing the iframe child print dialog (Hoping you're not using a form at this time so it won't submit again): On ... read »
May 14, 2013 at 7:13 PM
What If All User Interface (UI) Data Came In Reports?
@Jonah, If there's any books you'd recommend on the subject of domain modelling, I'd love to hear it. I just downloaded the free PDF of "Domain Driven Design Quickly". Figured I'd give it ... read »
May 14, 2013 at 6:57 PM
The UX Of Prototyping: Low-Fidelity Is The New High-Fidelity
@Phillip, I'm not sure I follow what you mean? Are you saying that you looked at the list of widgets provided by the jQuery UI and let that be your style guide? ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools