Stop subverting the Web
Web apps should be RESTful
In March 1999, nine years after the first website, Microsoft quietly transformed the Web. With the introduction of the IXMLHTTPRequest object, Tim Berners-Lee’s stateless document retrieval system became a (slightly clunky) stateful application delivery system.
But beyond the elimination of a handful of page refreshes — this really didn’t have much of an effect. During the following ten years, as companies migrated applications to the Web, applications typically still followed the old stateless server-driven approach. Web technologies were just not powerful enough, and browsers too darn inconsistent to do it any other way (although there were exceptions such as Gmail).
And until recently, if web developers did attempt something more involved, the prevailing mindset was that user agents without JavaScript should be supported as a matter of best practice.
The traditional stateless model of websites continued to function.
Today, all the main browsers are roughly standards compliant and provide a consistent platform upon which to build complex applications. But this brings with it a certain responsibility for implementors. As developers, we now have the ability to completely subvert the original hypermedia nature of the Web.
Positive Externalities
The design philosophy behind the Web is REST. There is even a four-point scale so you can see how far you have strayed from the ideal.
In web application terms, making your application RESTful involves using HTML anchor and link tags to provide hyperlinks between documents, and HTML form tags to perform actions against resources. If you do this, both humans and computers can better understand your application — and you get lots of helpful side-effects. Such as:
- Search engine indexing
- Different content rendering modes in browsers to improve readability and accessibility
- Support for a wider variety of user agents (for example, cars, translation services, and mobile devices)
- Enabling the sharing of specific information within your application via URLs (and shortening services)
- Giving the user a sense of confidence in their location within your application via the browser address bar
- Improved discoverability, through enabling users to navigate either via hyperlinks presented to them or through educated guesses based on a consistent URL scheme
In short, REST and is an important part of what made the Web so successful in the first place.
The point of it all
Unfortunately, there is an emerging trend amongst web applications that seems to dismiss the hypermedia roots of the Web as anachronistic — an annoyance to be tolerated. And in so doing, they spectacularly miss the point.
The point of the web is sharing — both with humans and computers. If you want to send me a link to a used car, then you can. If you want to copy all the text from a news article to paste into an email, you can. And if googlebot wants to build a model of your website or web application so that users can more quickly find the information they need, it can.
If you are not careful in your application implementation, these positive externalities are quickly lost and your application is the worse for it.
Abuse
If you want a good example of how not to create a web application, you really don’t have to travel very far. In fact you’re probably already there in another browser tab — and they really should know better.
I am talking about LinkedIn.
It’s bemusing. They must have some intelligent people working for them or their contact suggestion algorithm wouldn’t creep me out so much. But said overachievers are clearly not working on the web application itself. Try logging-in and navigating to your profile page. Then click the big Edit button. Now hit the back button. Boom — you are back on the hompage.
Or try deep-linking into a profile. Sometimes this actually works. Other times, not so much. End result: a vague sense of ennui every time you use the site.
The Challenge
From a technical stand-point, being a good Web citizen is straightforward: deep linking works, meaningful URLs, back and forward buttons work as expected and so-on.
Instead, the real challenge is the shift in mindset. Do you accept that you are building a hypermedia application? Do you want to be a good citizen of the Web or not? Because frankly, it’s going to take a little extra work.
If you’re developing an application using HTML, JavaScript and CSS then you should understand and respect the principles behind the Web.
If you don’t, you may as well write a Java applet.