Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: Joel Taylor
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: Joel Taylor

Learning jQuery By PACKT Publishing

By
Published in , Comments (6)

While there are a lot of Javascript libraries out there, there's something special about jQuery. Right when you start to use it, it just feels right. Of course, trying to sell a manager or a co-worker on, "it just feels right", rarely works; it's important to be able to list out the reasons why something is good. Learning jQuery by PACKT Publishing, co-authored by Jonathan Chaffer and Karl Swedberg, does this for you - the very first chapter starts out by taking what you feel in your gut and wrapping up in 12 powerful bullet points. Not only does this set the expectations for the rest of the book (which are met with flying colors), it gives those of us who cannot easily codify our thoughts a pre-packaged strategy for introducing jQuery into the work place.


 
 
 

 
Learning jQuery by PACKT Publishing, Co-authored By Jonathan Chaffer And Karl Swedberg  
 
 
 

Having read the jQuery Reference Guide prior to this book, it is clear that Learning jQuery does not cover the entire breath of the jQuery library. It does cover a good deal of the selectors, DOM traversal and modification methods, AJAX functionality, event binding, and plug-in architecture, but to be sure, there are things that are either glossed over or left out. This should, however, not be viewed in a negative light. Instead of being incomplete, Learning jQuery takes the most important and powerful aspects of jQuery and covers them in-depth.

This book is all about the in-depth, iterative example! After every chapter, I found myself reflecting on how thorough and well done the examples were. Each one starts out with a simple piece of code (probably the way you or I would accomplish some task). Then, it adds something. Then, it factors something out. Then, it encapsulates something. Then, it adds some more functionality. At each step, I kept thinking, "Brilliant! I can't believe I never thought of doing it that way." At the end, not only do you understand the jQuery concepts in a way that the reference guide could never communicate, you've completely changed the way you want to write your own code.

I think it is very important to note that all of the code examples are done in a "progressive enhancement" way. By this, I mean that all of the examples are designed to function at some level, even for web users who have disabled Javascript in their browsers. It is only through Javascript that the advanced features are added to the page once the document object model has loaded. By "upgrading" the page functionality in this way, not only do you keep your markup very clean, you ensure that the page works for everybody. I've never even thought about doing things this way; I'm telling you, this book is inspiring.

While there is too much great content to cover on a piece by piece basis, there were many aspects that I thought were very exciting to learn about. Of particular interest is the use of CSS class values as a means for hooking into the DOM. Traditionally, I have only used CSS to format elements within the page. Many of the examples in this book use arbitrary CSS classes, not for formatting, but for targeting parts of the DOM using jQuery. For example, a column header might be given the class, "sort-asc", not because it has any formatting associated with it, but rather because it allows the sort direction of the column to be defined in a way that can be easily accessed and located via jQuery selectors. This concept really blew my mind! I had never thought about using classes for anything but formatting, but I can see how powerful this technique can be.

One of the other things that I wanted to point out is that this book describes writing jQuery code that takes place over time. That is, it explains how to write jQuery code that does not fire immediately, but rather executes several times over the course of time. I have hardly seen any documentation or examples of jQuery code that uses the setTimeout() or setIterval() methods, but this book has an example that uses these methods and explains their application quite well.

In addition to the jQuery information, just by fact of how in-depth the examples are, this book ends up teaching you more about Javascript in general. I like to think of myself as having a fairly good understanding of Javascript, and even I came across several useful functions that I had never heard of before, but am already excited about using in future projects.

This book also has the best explanation of Javascript Closures that I have ever read. In fact, they have a whole Appendix (Appendix C) dedicated to the concept of Closures. I don't know if it's just because I am at a point where I can start to understand what it is that they are, or if this book just does an excellent job of describing what they are, how they work, and how they relate to jQuery, but something about their explanation just took the concept and drove it home. So much of the power of this library is derived from the nature of Closures, so, while the understanding of Closures is not necessarily essential for the basic usage of jQuery, it is certainly essential to understand when creating complex, object-like functionality. I almost want to say, if for no other reason, you should get this book for Appendix C alone; that's the kind of eureka moment that I had when reading it.

Overall, this is a great book, and a must-read for anyone who is serious about learning how to write powerful and concise jQuery code. While the reference guide is good, it cannot hold a candle to this book in terms of teaching; in my experience, it is only through great, in-depth and iterative examples that learning can take place and Learning jQuery provides these type of examples almost in excess.

Reader Comments

33 Comments

Decent review!

If you fancy learning a whole lot more about JavaScript, including closures explained brilliantly, read Pro JavaScript Techniques by John Resig (lead developer of jQuery). Fantastic book on writing professional JS. Quite an eyeopener :)

22 Comments

Ben - I trust your recommendations and ordered a copy today. I'll let you know what I think. I've been heavily into Flex 2 development but am relooking at ajax and DTHML widgets for enhancement to some existing web pages.

15,841 Comments

@Bruce,

I think you are gonna be happy with it. Some of the examples are really long (the Table chapter goes on forever!), but take your time getting through it; it will pay off.

96 Comments

I have the first edition of learning JQuery ... it's a good book ... But I'm currently reading JQuery In Action by Bear Bibeaullt & Yehuda Katz and I'm learning about as much as I did with the JavaScript Bible by Danny Goodman ...

Thanks for all your incredibly effective demos Ben ...

:)

E

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