Learning jQuery 1.3, the book

Not too long ago I acquired a copy of “Learning jQuery 1.3“, a recently released ‘PACKT’ publication written by Karl Swedberg and Jonathan Chaffer. The only books I’ve previously owned relating to web development were not framework/library specific so reading this one was a totally new experience.

The book is mostly aimed at beginners but does cover some more advanced topics so may be of interest to the more savvy web designer or developer. Actually, anyone wanting a solid jQuery reference would benefit from this book!

I’d guess that one of the troubles with writing a book just about a specific topic is that you’re limited to its confines. This book does not start by discussing the DOM API or JavaScript itself, but instead it begins by first explaining the intent of jQuery and then by detailing the jQuery wrapper function and how you can utilise the power of CSS within this magical dollar symbol. jQuery is wonderful but, in my opinion, without a solid foundation in JavaScript you can never be as good as you could be.

The authors did a wonderful job and I don’t think anyone could ask for a better book about jQuery but I cannot help but raise the question of whether or not jQuery is the practical place to start.

I have this image in my head of some hotshot interface designer longing for some hotshot Ajax’y coolness to suit his ego; he wanders into Waterstones and picks up a copy of this jQuery book he’d heard of, he takes it home, and willingly begins on the long journey of learning “jQuery”. If the world were what I wanted, then this guy would soon realise the error of his ways and how he should have learnt JavaScript before venturing into it’s squeeky clean abstractions; but, unfortunately, the world is not like that; the reality is more upsetting – not only will this designer never realise the error of his ways but he’ll live on, writing jQuery everyday, creating bouncy effects and “jQueryfied” web interfaces. Why is that a problem? – Because he will never be able to program in JavaScript he’ll lack the fundamental knowledge that would otherwise ensure him complete cross-browser and timeless sanity!

Did you see that!? While discussing the necessity of learning JavaScript before jQuery, I went off at a tangent; Something book authors are not afforded the luxury of doing… But that isn’t to say it was a worthless moment! That’s why books bug me a little, it’s all about size, specification and compensation! It’s never really about the information. 1

Back to the book…

The book goes into considerable depth and manages to cover most, if not all, aspects of jQuery. In addition to feature descriptions and examples, Karl and Jonathan discuss best practices and continually advise the reader on the best course of action in various situations. jQuery’s UI framework and other various plugins are also discussed near the end.

I only have a couple of concerns about the book and its content. I don’t feel that the surrounding technologies are given enough time in the book. A preliminary chapter on the basics of JavaScript (and the DOM) would’ve certainly benefited beginners. While the average reader might not see the relevance of such a chapter, they’ll probably have a better understanding of the syntactic discrepancies of jQuery because of it. Even though having knowledge of JavaScript is a noted prerequisite, I doubt many readers of the book would accept this necessity. Beginners are vulnerable to the classic mistake of learning a framework before learning the language on which it’s based.

The only issue with offering such a chapter would be that half the readers would probably find it either useless or not worth reading… yet another reason why books bug me, you’ve got to cater to such a large audience with such varying motives that you’re bound to disappoint at least a few of them!

I only have one other tiny problem with the book, and this is very specific issue and probably a little over-zealous of me to even mention it: In the first chapter the authors state that without jQuery’s bespoke ready event you’d have to rely on the onload event to run code when the DOM is loaded. Then they continue by saying how you’d have to bind a named function to the event by obtrusively placing it in the HTML (<body onload="...">). These assumptions highlight a notable problem with jQuery and its “marketing” techniques: The conception that unobtrusive JavaScript is only possible with jQuery is far too widespread, even the assumption that jQuery makes unobtrusive coding easy is, in my view, rubbish. There are far more respectable ways to market a product (i.e. jQuery) than slamming the competition (i.e. JavaScript without jQuery). 2

Conclusions

The content of the book, as it is, is definitely up to scratch. The only issues I have are more theoretical and are largely unrelated to this particular publication.

If you are considering buying a book of this type or are possibly on the edge of a decision then I absolutely suggest this one! Everything you’d want to know about the jQuery library is neatly squeezed inside the covers of “Learning jQuery 1.3“. Don’t be put off by my negativity; like I said, those are just a couple of my opinions concerning the general approach of books like these, not the content of this particular one.

Even if you’re not considering buying any book at all, I would definitely consider looking at this one. Although, if you’re a total beginner I might suggest a more gentle and progressive introduction to the world of JavaScript, possibly “JavaScript: The Definitive Guide“. If you can’t be bothered with “regular JS” and just want to get at the cool stuff then I urge you to reconsider your stance. JavaScript isn’t as bad as people make it out to be, and it’s only getting more popular; learn JavaScript, then learn jQuery (or a library/framework of your choice).

1 – By this, I mean “information” is rarely the prime concern when publishing a book. While creating an informative book may be the sole objective of the author it’s not going to be the publisher’s primary concern!
2 – Library’less JavaScript is not in competition with any particular library but the marketing techniques of these libraries has created this dillusion; that JavaScript is not good enough, and that somehow it’s all too hard…

Thanks for reading! Please share your thoughts with me on Twitter. Have a great day!