Speed up your coding using quick and easy JavaScript

JavaScript Mobile

I now want to show you some of the JavaScript libraries and frameworks, albeit only a few, that are making their way into the mobile development community. Mobile is kind of like the Wild West revisiting us again; we're heading into unchartered landscapes and JavaScript for mobile web apps shouldn't be treated as like-for-like in the desktop world.

There are any number of considerations to be met: performance of the mobile device, whether you want to replicate the native UI and whether the mobile device even supports the newest JavaScript methods.

XUI

XUI is another project started by Brian LeRoux of Lawnchair. It's a super-tiny, 3k-compressed mobile JavaScript library akin to jQuery and designed for simple DOM manipulation and traversal. It also includes Ajax and Effects via Emile.js.

As per jQuery, it supports the simple xui.fn.myplug plug-in model, so it's completely extendable. The project aims to be compatible with mobile browsers based on WebKit, Mozilla's mobile browser Fennec, Opera, IE and BlackBerry. It's still in-project but is stable. I'd recommend getting the source from GitHub.

jQTouch isn't so much a framework as a jQuery plug-in that provides a native UI feel to iPhone-based web apps. This includes transition effects, a few template styles for all the UI widgets (such as lists, buttons and toolbars), swipe detection so that it interacts like an iPhone app and, finally, the ability to extend the functionality of the plug-in.

A number of jQTouch-based iPhone apps have already been submitted and are available in the iTunes store, compiled via PhoneGap. I even saw live coding demos by Jonathan Stark during the SXSW conference, showing how he was able to get jQTouch up and running in a simple web app in a matter of a mere 10 minutes.

Finally, I feel compelled to include an honorary mention to jQuery in this section. John Resig has been busy testing mobile devices to understand what they're capable of and, most recently, he's said that jQuery will support a matrix of mobile browsers, akin to the Yahoo graded support matrix. He's also said that unmodified jQuery will support mobile browsers from B-grade and upwards. It's definitely one to watch.

Find what suits you

Selecting and using a JavaScript library, framework, micro-library or even plug-in can be a tricky job. I've shown you some of the projects out in the wild already, and there'll be a fair few more by the time you've read this.

As Ajaxian says: "A new Ajax framework is born every three minutes", and with all that choice, there's bound to be one out there that's perfect for you. So go find it!