found drama

get oblique

review: Eric Sarrion’s jQuery UI

by Rob Friesel

jQuery UI by Eric SarrionEric Sarrion’s jQuery UI (published by O’Reilly) is a beginner-to-intermediate level overview of the jQuery UI library and its widgets.1 Sarrion walks through these widgets one-by-one, chapter-by-chapter, offering a description for each, elaborating on the UI problem that each is designed to solve, and then detailing the API for each of these widgets. Each chapter is constructed after this pattern, illustrating how to setup your mark-up to best work with these widgets, how to initialize and interact with each widget type, and then showing some example implementations of varying degrees of sophistication.

If you are a JavaScript novice, or else are new to jQuery or its UI library, then Sarrion’s book is good for getting up and running fast. Each chapter is reasonably self-contained–e.g., if you just need to learn the ins and outs of the jQuery UI dialog(), then you can blow through chapter 4 in about 15 minutes and pick up enough to create a reasonably sophisticated modal dialog. Each chapter includes a series of tables that provide a quick reference for each method/widget’s available options, methods, and events. Further, the example code at the end of each chapter is a valuable way to get some ideas about how to put each widget into action.2 These explanations and examples are easier to digest than the documentation3 and examples that are otherwise available in the demos.

That being said, if you are a web development professional with sophisticated JavaScript knowledge, you may find yourself grinding your teeth all over the place here. And that’s not just because we’re talking about an elementary introduction to a popular UI widget library with an almost brain-dead-simple API. It’s because–as they say–the devil is in the details, and boy are there some cringe-worthy details:

  • Sloppy mark-up. Sarrion mentions that Internet Explorer needs a doctype, but then does not go on say what a doctype is, or why it’s necessary or what the consequences of omitting the doctype are… And/but then he doesn’t quote the attribute values in his sample HTML either. Even a footnote or two on such subjects would suffice.
  • Non-idiomatic JavaScript. Everyone has their own style, I get that. But there are some things that are just… strange when you see them. Sarrion apparently likes to put a space between the method name and the parens when invoking a function. I have never seen code like that before and had to go and look it up. Can you even do that?4 Opening curly braces on a new line, that’s one thing5, but a space between the name and invoking parens on every page was enough to make me want to scream.
  • Non-idiomatic and arguably dangerous JavaScript. Beyond “everyone has their own style”, we get into the area where you have valid code that is otherwise not really good code because its known to be error-prone code. I am talking (of course?) about single line if statements6, == comparisons, browser detection7, and other minor transgressions. I take issue with these mainly because of what I perceive to be the audience: if the book is targeted toward beginner and intermediate level devs, then we have a responsibility to set a good example.
  • Confusing details in the tables. I have a bit of a bone to pick with whomever was responsible for getting these tables together. First: the second (explanatory) column in most tables in more chapters had the heading “Function”. Granted, it is easy to figure out from the context that “Function” here means “intended purpose of the thing listed in the left column”–but this is a book on JavaScript and as such, it pays to be careful with that word; that word means something specific. Second: (and this is probably a more egregious error) don’t split function names. This may very well have been an accident, and looking back, I only see the one but… when the method name is getDate, don’t let it break onto two lines like that.8

The laundry list of quibbles aside, my two big disappointments were as follows: First: I was hoping for some more sophisticated coverage of the jQuery UI library. In a lot of ways, the text is just a re-hash and/or expansion on the jQuery UI documentation. This is fine for JavaScript novices, or else for folks that just want to get up and running with the library quickly9 and don’t care about a deep dive or its inner-workings. Second: I was also looking for more in the way of plugin development. jQuery UI is already a pretty feature-rich library, but there are always places where you can expand on it, or else create your own purpose-built widgets for your apps. There is no real discussion here of the library’s idioms or patterns, nor of how to approach extending the library or writing plugins or widgets around it.10

Again, if you’re a JavaScript lightweight and are just looking to get going quickly with jQuery UI–then this book could be super helpful for you. If you’re a bit more sophisticated… borrow your neighbor’s copy in a pinch, but don’t get your hopes up beyond what you’d otherwise be able to look up online.

Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.

  1. Sarrion’s jQuery UI covers version 1.8, but I noticed that it does not cover the position utility. As the position utility is currently flagged on the website as “new”, then I presume that the book went to press before that utility’s release. []
  2. Though I was disappointed that there was no associated Github repo. []
  3. I’m tempted to go as far as to say they’re “superior” to the official documentation, which I’ve always felt were sort of tacked on. It isn’t as though jQuery UI has a terribly complex API (it doesn’t, though it is quirky and idiomatic-unto-itself (which: “I guess it’s internally consistent, at least”)) — it’s just that the official docs focus more on the examples and bury the actual documentation “down there” below the fold, like an after thought. “Minus one to that”, if you ask me. []
  4. Turns out that you can. But: !?!?!? []
  5. A thing I don’t like, but whatever. []
  6. Doubly dangerous because they’re missing their curly braces. []
  7. As opposed to feature detection. []
  8. Table 8-9, I’m looking in your direction. []
  9. E.g., a junior or mid-level dev in an organization that is already using jQuery UI; e.g., an e-commerce shop that is heavy on back-end devs and just wants to put some quick polish on their site. []
  10. This is only partly true. I give Sarrion some big-time bonus points for the calculator example at the end of chapter 5 where he builds the thing up as a one-off, then re-factors it into a plugin-style widget. []

About Rob Friesel

Software engineer by day, science fiction writer by night; weekend homebrewer. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

2 Responses to review: Eric Sarrion’s jQuery UI

Leave a Reply

Your email address will not be published.