Friday 28 September 2012

The irresistible rise of JQuery

Last month a survey on W3Techs determined that the JavaScript library jQuery is being used by over half of all websites. This is a rise of 40% over a year and, according to the survey, means that a top website was adding JQuery every four minutes. Those fades, slides, calendars, form checks you see (and probably use on your sites) come from this amazing set of code. It stems from a software engineer named John Resig, who wrote about using Selectors in JavaScript almost exactly seven years ago. (See last month's item in the Register.)

I was very sceptical about JavaScript when it first emerged. It seemed to be an attempt to mix functionality with markup that harked back to earlier multimedia days: and many people turned it off in their browsers. Now that web-wizards are routinely separating form from content in web pages, and using CSS to deal with the form, JavaScript makes its stunning comeback. As it's an interpreted, if often arcane, scripting language it's easy to learn from others and freely distribute code.

What are the advantages of using Javascript-only versus using JQuery-only? That's a question asked on the Programmer Blog only a couple of days ago. The answers are interesting and make points that apply to libraries in general - such as the load overhead (you'll probably not be using all the library so you're loading unnecessary code but if you load from Google then it'll probably already be in the user's browser) - and some advantages of JQuery, notably the gentle learning curve. I'd add the open/free nature of it, particularly when compared with Flash.

Web designer depot looks at the the Good the Bad and the Ugly of JQuery (with some useful comments too). The author, Richard Lawson, makes the point that "John Resig and the other developers behind the jQuery project genuinely understand the time/money equation that faces web developers on a daily basis".

I should also remind you of the venerable CSS Zen Garden, if we're talking about form vs function. It's been around for a long time (and is expecting CSS1) but basically has a set piece of marked-up content and you're invited to add your own CSS to change the look. It's a neat demonstration of a key principle.