How to write for mobile, without writing for mobile
What do we do, as web developers? Do we write a web site? What about an iOS application? How about an Android app? Should we look at Windows Phone 7? Should we even consider writing a Blackberry app? Do we make a mobile version of our site?
Questions, questions
It’s a difficult proposition, what to write. On the one hand, Apple sold 37.5 million iPhones and 15.7 million iPads in three months. That metric alone says to write the iOS application. What about Android? It’s hard to pinpoint an exact number, but lets say the last quarter saw about 40 million Android phones get sold. Windows Phone 7, a bit of a rounding error. Blackberry?
One thing most of these platforms have in common is an advanced WebKit based browser. This means instead of writing one app many times, we can in theory write it once and the mobile browsers just do the right thing. This isn’t a new way of designing web applications. It’s been the de-facto way of writing web applications for last couple of years. Let’s just call it “standards first.”
Thing is, that does nothing to tailor the site to the device. A standards first web site will work on mobile WebKit every bit as good as desktop WebKit. The problem is it’s more than just the rendering engine, it’s about the experience the user encounters with your site.
Writing an app versus writing a mobile site
The next thought typically is to either design a native application or a separate mobile version of the standards first web site. Let’s take those one at a time:
Application
- Tailored to the specific device platform
- Fast
- Expensive to develop
- Separate effort to maintain
Mobile site
- Styled to look pseudo native
- Faster than the regular web site, slower than a native app
- Less expensive to develop than an app, more expensive than standard development
- Separate effort to maintain
Some may take issue with my assertion that a mobile site is a separate effort. Look at all the sites that redirect you to a m.* version of the web site when you visit with your phone. That’s separate development.
What about responsive design?
Yes. I’ve left that one out for now. In cases where you are totally green-field, a responsive design, where you write mobile-first and can tailor for each expected device orientation in the beginning is the best approach. However, like the application and mobile site approach, responsive design has it’s share of pros and cons:
- Optimized for device size and orientation
- Slower than native app
- More initial development than standard development, but not significantly more
- Difficult to pull off unless you are starting from scratch
Stop talking about things not jQuery Mobile!
A fourth option has come about somewhat recently that is very exciting. The jQuery Mobile team has attempted to provide the advantages of building an application without having to invest the resources. Having the cake and eating it, as it were.
View both examples on a phone if you can
Listing users
Listing users
| Name | |
|---|---|
| <%= user.name %> | <%= user.email %> |
Same page, using jQuery Mobile
Users
<% @users.each do |user| %>
- <% end %>
<%= user.name %>
<%= user.email %>
That’s a lot of awesome for a very minor restructuring of the code. It makes things finger friendly as well as does a good approximation of what a native app looks and acts like. It’s clear that the developers of the framework used iOS as their model, however users of Android and Window Phone 7 devices will also benefit from the larger touch targets, even if the skin reminds them of an iPhone.
What gets really interesting is what happens when you start linking pages together. The framework makes client side requests for links instead of doing full server post backs. This gives the appearance of a more application like presentation, but without the application developer needing to do the ajax wire up themselves.
Like any framework there is a learning curve. Where in native development it’s sets of API’s and coding conventions, here it’s CSS styles and page structure. It’s up to you to decide which set of compromises is best for your environment.

