BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles Javascript and JQuery - Book Review

Javascript and JQuery - Book Review

Bookmarks

JavaScript and JQuery is an introductory guide to core parts of JavaScript and the jQuery library. It is a highly visual book and clearly aimed at an audience with a design, rather than a technical or coding, background.

The layout is clear, simple and for the most part graphically engaging. Concepts are explained using graphics and diagrams wherever possible. Short summaries feature at the beginning and end of each chapter, and are typically well-written and clear. There are also extended examples at the end of most chapters that build in complexity over the course of the book as the reader learns.

No attempt is made to gloss over the details between browsers, with definite emphasis on Firefox and Chrome. IE is mentioned and covered in less depth, but the obvious implication is that this is only because too many clients still use it.

The first chapter ("The ABC of Programming) is rather a slow start. The book expects the reader to already have quite a detailed understanding of HTML,
including working directly with raw markup and CSS. It seems somewhat odd, therefore, that absolutely no programming experience is assumed - even to the point of explaining that a program (which the book insists on referring to as a script throughout) is similar to a recipe or an employee handbook. This seems rather an odd assumption given how interconnected JavaScript is with modern HTML and CSS.

Despite this, it is refreshing to read a book so clearly written for the visually-oriented designer, rather than the endless series of books that try to shoehorn the designer into a coder's worldview.

The next three chapters deal with basic JavaScript programming, and the author has done a decent job of explaining concepts in a way that is accessible for beginners. It is very difficult to provide a completely watertight route into programming for the novice and so while a large majority of the content is very good, there are a few missed opportunities.

For example, variables could better be explained as "named boxes" and values as their "contents". Explanations and examples do not always flow from one page to another, which can lead to some sections feeling rather disjointed and could confuse readers. Some pages are a bit crowded, with certain concepts being introduced relatively early on, sometimes without a lot of supporting context (e.g. array constructors are introduced before we've really met objects).

The slow start of Chapter 1 contrasts quite sharply with the swift ramp-up of Chapters 2-4, and the reader is very quickly expected to understand more advanced concepts such as anonymous functions.

There are also some unfortunate omissions. Operators are introduced early on, along with a loose notion of typing. However, there is no discussion of operator precedence or type conversion rules. These would seem to be ideal candidates for a quick reference card in an appendix, with a short call-out in the main text.

On the whole, however, these problems are less severe than those possessed by many other introductory books and the level seems about right for the target market. Furthermore, the author makes a clear attempt to provide more thorough coverage of the core JavaScript language than other books aimed at designers and this is a big plus point for the book.

The next two chapters deal with the Document Object Model (DOM) and browser events.

The DOM chapter is excellent, with clear exposition that builds steadily on solid foundations and illuminates key techniques, such as understanding the DOM, traversing it and updating elements. Showing this in low-level HTML is an obvious foundation stone for the jQuery material, and is another example of thorough coverage.

(Click on the image to enlarge it)

The section on XSS is welcome, as too many frontend developers still remain unaware of the dangers of cross-site attacks. Having said that, it is slightly disappointing that the mitigation techniques focus on blacklisting dangerous characters, rather than whitelisting safe input.

Sadly, the Events chapter is less good and is rather uneven in terms of depth and coverage. For example, a well-presented table of commonly-encountered events is both clear and useful. By contrast, the description of event flow is sandwiched rather awkwardly between two very text-heavy sections, when it would help comprehension to be placed earlier. Likewise, relegating the deprecated techniques and IE-only workarounds to an appendix would also help the chapter to flow better. As it is, it feels rather clunky and text-based and this disrupts the smooth running of the book so far.

With the first half of the book behind us, the next two chapters introduce jQuery, AJAX and JSON.

The benefits of using a higher-level framework such as jQuery, rather than writing raw HTML have been discussed at length, but this book takes the approach of "show" rather than "tell". By this point, the reader has already been carefully led through the process of using DOM queries and so jQuery's selectors can clearly be seen to be much nicer to work with.

Some sections could have been clearer, such as "Key Differences from DOM". More could also have been made of the pipeline outlined in the chapter's opening summary - the Select Elements -> Perform Tasks -> Handle Events approach is a great concept and could have been built on more extensively.

Chapter 8 starts with a good explanation of what AJAX actually is. This encourages readers who may not have consciously thought about how a modern web page or webapp actually works. The data formats section is unfortunately less good, with only a one page description of XML, that glosses over a lot of important detail. This seems bizarre given the depth given to some topics in earlier chapters. XML-based AJAX services are clearly on the way out, but are still widely deployed and this seems like an odd place to have omitted detail.

Also worrying is the description of JSON, and in particular the rather clumsy distinction drawn between on-the-wire format and object representation. Still, at least the coverage uses the proper parsing API rather than eval().

The coverage of jQuery's support for AJAX querying and loading is fairly thorough, including a good discussion of AJAX error handling, although the description of the forms functionality was somewhat less impressive.

The next chapter focuses on APIs, and was by far the weakest of the chapters so far. The descriptions of the distinction between new browser APIs, framework or script APIs and hosted APIs such as Google Maps was completely unclear, and the distinctions between them seemed to be being deliberately muddled. The API chapter ends with an extended usage of the Google Maps API, although this is not tagged as an example.

Following the API chapter is the Debugging chapter, which is excellent and a welcome return to form, although it is strangely placed in the book - it would be far more useful earlier on (perhaps even before the Events chapter). This chapter includes an introduction to debuggers and to concepts such as the execution stack and exceptions, as well as debugging tips, common errors and pointers to additional external sources of help.

Chapter 11 introduces the basics of simulating true application UIs within JavaScript, via the concept of a "content panel". While this is an unfortunate necessity of modern web design, it seems overly rushed compared to the depth in which some other subjects were treated earlier. This is rather unfortunate, as this is one of the most complex sections of the book.

Chapter 12 expands on the treatment of jQuery's selection pipeline by introducing filtering, search and sorting capabilities. This, again, is a necessary, but complex set of concepts covered in not very many pages.

The final chapter, Form Enhancement and Validation, is a strange choice to wrap up the book. Not only is it considerably easier to grasp than most of the preceding two chapters, it only makes fairly light use of jQuery. Once again, it would have made for a better flowing book and a more even learning curve if this chapter was placed earlier in the book, and the complexities of the two preceding chapters were used to conclude the book.

Overall, a lot of the book is beautifully presented, but some flows are missing or are only addressed with text-heavy flows that detract from the visually appealing sections. This can lead to a jarring experience when a text-heavy exposition derails the reader. This is exacerbated by some of the sections being oddly placed.

The compromises the book makes by teaching actual foundations and striving for proper comprehension bump up the size of the book. They may also drive away some more impatient readers. However, this is unquestionably a better book for the additional material and most readers will come away better prepared and better educated because of it.

Ultimately, the only real nagging doubt is whether it is too much of a stretch to go from "a script is a bit like a recipe" all the way to writing jQuery plugins
and the beginnings of functional programming idioms in a single book. The majority of the book is very good indeed, but the sense that it might be trying to do too much remains after having finished reading it.

About the Book Author

Jon Duckett, author of JavaScript and jQuery: Interactive Front-End Web Development, has been designing and building websites for over 15 years. He has worked with small startups and global brands, and has written more than a dozen books on web design and programming. For more information please visit www.javascriptbook.com

Rate this Article

Adoption
Style

BT