Over a million developers have joined DZone.

Interview: Authors of jQuery in Action

DZone's Guide to

Interview: Authors of jQuery in Action

· Java Zone
Free Resource

Just released, a free O’Reilly book on Reactive Microsystems: The Evolution of Microservices at Scale. Brought to you in partnership with Lightbend.


According to Manning, the purpose of this book is to help you learn how to do more on your web application pages with less script. Bear Bibeault and Yehuda Katz, one a jQuery contributor and evangelist and the other an avid and enthusiastic user, believe that jQuery is the best library available today to help you do just that. In this interview to Javalobby, the authors tell us more about their book and jQuery as well.


1. Bear, Yehuda, tell us something about yourselves. Who you are, where you are located, and what kind of work do you do?

[img_assist|nid=1985|title=|desc=|link=none|align=left|width=100|height=100] Bear: Shouldn't there be a microphone? I've alway wanted to be interviewed with a microphone.
Well, I'm a software engineer living and working in Austin, Texas. I've been writing code for over three decades now, and besides having had exposure to just about every production language that?s been popular over the years, I've held positions from junior engineer to development manager.

Right now I've settled into a cozy niche as the architect for a large financial web application that's used by big companies to keep tabs on their internal credit card spending programs.
It's really not as boring as it sounds -- if it were, I'd have died of tedium long ago.

[img_assist|nid=1984|title=|desc=|link=none|align=left|width=100|height=86]Yehuda: I currently live in San Francisco and work for Engine Yard. We do a mix of Ruby on Rails hosting and Ruby development. I have the good fortune to be working full-time on Merb, an alternate (OSS) Ruby web-framework, which has been picking up steam lately in the Ruby community.

I also get to work on Rubinius from time-to-time. Rubinius is an up- and-coming Open Source Ruby VM, which is based loosely on the Smalltalk-80 VM. It's intended to be fully compatible with the current Ruby interpreter, but be written, as much as possible, in Ruby itself.

2. I see that you have a upcoming book “jQuery in Action”. Is this your first book?

Bear: No, actually it's my third, coming close on the heels of Prototype and Scriptaculous in Action, and Ajax in Practice. I've been writing non-stop for coming on two years now,and I think I'll take a bit of a break and try to remember what the rest of my house outside of my office looks like.

Yehuda: Yep. It's my first book. I contributed two chapters to Ruby in Practice, and am currently working on Merb in Action, all for Manning.

3. Who is your target audience?

Bear: For the jQuery book? Anyone who needs to write JavaScript on their HTML pages. It doesn't matter if it's for simple web sites or wildly complex web applications -- jQuery will make it easier.

Yehuda: It helps to know something about JavaScript, but if you don't, we've included a helpful Appendix to get you up to speed in the areas that are most relevant to jQuery.

4. What is jQuery? Is it a new type of JavaScript library?

Bear: Yes, exactly! In fact, that's precisely how they bill themselves -- as a new type of JavaScript library.

Yehuda: Our original tagline was "New Wave JavaScript", and our original logo was the Devo hat. This was before we had any inkling that we would be remotely successful, of course ;)

Bear: And it does take a rather novel approach. They promote a style of page scripting called “Unobtrusive JavaScript” and the library itself is as unobtrusive as possible.

5.How so?

Bear: Most JavaScript libraries are pretty invasive. They litter the global namespace with a bunch of new variables and “class” names, and some even go so far as to modify the behavior of the native JavaScript objects.

jQuery takes a bit of a different approach. It only defnes two global names, and one of those is even optional!
That conveniently side-steps any pitfalls you can come across with other libraries, like when native objects don't act as expected, or having to worry about what names we canor can't use on the pages.

It also means that jQuery works and plays well with other libraries. If you want to usemore than one at a time for whatever reason, nothing in jQuery gets in the way of doingthat.

Yehuda: jQuery has even been cited by the OpenAjax Alliance (an industry consortium seeking to improve interoperability between JavaScript libraries --http://www.openajax.org) for being a model citizen in this area. We're proud of the way we have made it possible to use jQuery with even the most ill-behaved libraries, and even with libraries who explicitly refuse to work toward interoperability.

6. Why should we be using jQuery?

Bear: Because jQuery rocks!
Seriously, all of the reasons I already mentioned, but mostly because it just makesdoing the types of things we want to do in modern web applications so darned easy! In the book, I called this “doing more with less”. And that's exactly what jQuery brings to the party. You can write a lot less code, and do lot more nifty things on the pages. What's not to love?

Yehuda: Most of the time when writing Ajax applications, you find yourself needing to do something to some collection of elements. jQuery was built around this notion(Jeremy Keith calls it DOM-Scripting), which means that your day-to- day work is also the central mission of the framework.

jQuery doesn't spend tons of time trying to make JavaScript look like another language (like Ruby or Python); it leverages JavaScript's benefits while dramatically improving DOM functionality.

7. What browsers support jQuery?

Bear: It's sort of the other way around. jQuery supports all the modern popular browsers: both isotopes of IE (6 and 7), the Gecko-based browsers like Firefox and Camino, the WebCore browsers like Safari and OmniWeb, and even Opera.

And like any good JavaScript library should, it insulates the page author from having to worry about dealing with all those completely irritating browser differences that drive us all crazy when we're just trying to get stuff done!
This is especially nice in areas like event handling and Ajax where the browser quirk shave always been a royal pain in the keester!

Yehuda: Heh. Yep. My favorite chapter in jQuery in Action is the event chapter, which details how the "jQuery Event Model" works. After detailing the flaws and complexity in the other event models, we show you just how easy jQuery makes it.

8. Can you tell our readers how jQuery works?

Bear: Sure. What makes jQuery so easy to pick up quickly is that most of the jQuery statements follow a similar pattern. You use the jQuery function to select which DOM elements you want to operate on, and then apply the jQuery methods to that set. You can even chain multiple commands to perform complex operations in a single statement.
It's incredibly easy to start being productive with jQuery right off the bat, and then get more and more clever with it as time goes on.

The jQuery selectors, which are simple CSS-based expressions that succinctly let us specify which DOM elements to choose for operating on, are the key to using jQueryeffectively.

Yehuda: jQuery supports almost all of the CSS3 selector set (except for a few arcane ones like :nth-child-of-type that were literally never used), as well as a numberof convenient additions like positional selectors (:lt, :gt, :eq), and form selectors(:button, :text, :radio, :selected).

9. Any tips and tricks for our readers who already are using jQuery?

Bear: Yes. Really spend some time wrapping your head around the jQuery selectors. Learning the methods is easy -- it's using the selectors cleverly that really gives you a lot of bangfor the buck!

Yehuda: I agree 100%. The best thing you can do to improve your utility from jQueryis to learn the available selectors.

Strategies and techniques for building scalable and resilient microservices to refactor a monolithic application step-by-step, a free O'Reilly book. Brought to you in partnership with Lightbend.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}