How AJAX jacks-up web app performance

2012-02-19 @ admin

It’s ‘next big thing’s tend to revolve around stuff that’s new. AJAX application design is different – it’s made-up from things that are all quite old – in Internet years, at least – and unashamedly borrowed.
From a blog post by Jesse James Garrett, founder of startup Adaptive Fath, through the launch of high-profile Web applications by Google and Yahoo among others, AJAX has become the latest movement in online applications development. Bolted together from technologies developed in the mid-1990s, AJAX is designed to streamline clunky browser-based front-ends.
AJAX applications use a mixture of javascript, XML, Cascading Style Sheets (CSS), and the Document Object Model (DOM) supported by most modern browsers to make thin clients just that bit thicker. This, it’s claimed, makes web applications more responsive, and loosens the tight connection now needed between client and server.
The acronym AJAX itself comes from ‘asynchronous Javascript plus XML. The asynchronous part refers to the way that smart AJAX code requests data from the server in dribs and drabs in the background, without stopping the user from working with other data on the page.
The highest-profile AJAX application, Google Maps, uses this approach to fetch large chunks of data at first, and then use client-side scripting to let the user scroll around that, only fetching more if the scroll moves outside the cached area.
Yahoo Mindset uses CSS and scripting to selectively hide search results based on how the search engine categorises them. For example, a search on ‘iPod’ will pull up a regular search-results page, but a slider at the top – here running between the ‘shopping’ and ‘researching’ ends of the search spectrum that Yahoo assumes exists around the music player – lets the user concentrate on different types of result.
Sliding it all the way to the left will hide the researching and many only vaguely shoppingrelated links; but moving the bar only slightly to the left will reveal less commercial pages.
It is not just search engines making use of AJAX Zimbra is an open source email application designed to replace Lotus Notes and Microsoft Exchange with a completely web-based system. Others are looking to supplant the Microsoft Office tools, such as Word. Witely is one such distributed word processor.
Relaxing the link between server and client means that every editing operation does not need a refresh at the server end. According to Nate Root, analyst at Forrester Research responsible for a research note on AJAX, the relaxed link can provide a modest, but measurable, improvement in bandwidth efficiency, coupled with a more responsive client. “Your users will get more done in less time,” he promised.
That does not mean AJAX is without its problems. Ferformance can be an issue, said Bola Rotibi, senior analyst covering the application life-cycle at Ovum: “Applications that use a lot of Javascript will tend to be slow.”
The use of small, behind-the-scenes XML data transfers breaks the link between the browser’s back-button and the user’s last action. How to handle this? Toolkits are appearing that fix the problem, but such work incurs an overheard. “If you look at some of the applications that use AJAX, such as Google Maps, you think, Wow, that is pretty impressive’. But Google has put a lot of work into it to make sure they have addressed things like the back-button problem.”
Then there is the issue of cross-platform compatibility. The use of a browser as the front-end implies you can use AJAX on any client. That is not quite the case. One tiny, but crucial, component – the one that makes it possible to fetch data in the background – was designed by Microsoft. The idea behind the XMLHttpFtequest object, which was implemented as an ActiveX object in Internet Explorer 5, released in the autumn of 1998, was to make it possible for web browsers to fetch data from a server in XML form without having to reload an entire page.
The idea was so attractive that a comparable version of the object was incorporated in the Mozilla browser and also in Apple’s Safari. However, despite this, AJAX applications are not quite as platform-neutral as their more enthusiastic advocates claim.
There is no official standard for the object,
so browsers deal with it in different ways. As a result, AJAX applications will either break in some browsers, or the server code rejects accesses by unsupported clients. Writely will generate an error message if accessed with Safari rather than Firefox or Internet Explorer.
Tools remain an issue for would-be AJAX developers, although there is movement here by both big players, such as Microsoft, and by startups. In September 2005, Jim Allchin, vice president of the platforms group at Microsoft, told developers at the company’s main technical conference that its Atlas toolset would support the AJAX approach.

“Applications that use a lot of Javascript will tend to be slow” – Bola Rotibi, senior analyst, Ovum

“If you have done any of this code today you know it’s pretty hard. Ybu have to be an expert in DHTML and Javascript. Y6u’d better understand all the differences in all the different browsers, and there are subtle differences,” said Allchin. “You’d better be good with some tools, because the tools aren’t as great as they could be – and debugging is, frankly, pretty hard.”
“What we’re trying to do is create a framework, an extension of ASRNet, that will let you build rich Web experiences without the pain that you’re currently going through doing this client-side scripting.”
In the open source world, toolkits such as Dojo have emerged that provide a set of ready-rolled Javascript components. Alex Russell, one of the people behind Dojo and a programmer at wiki specialist Jot, said the reasoning behind producing a toolkit was the amount of “wheel reinvention” the development community has been doing. “Everyone has been coming up with their own DHTML toolkit,” said Russell.
Javascript currently lacks a lot of the advanced tools that other developers get. “Javascript programmers are used to putting up with a lot,” Russell avered.
But, he said, much of the attraction of the language comes from its lightweight nature: “It is not a class-based language, which throws a lot of people. But the language does not carry much. A lot of its penetration is because it is not carrying around a huge class library.”
Over the next year, javascript and AJAX as a whole will acquire a lot more infrastructure to ease development. However, Rbot warned: “It’s possible to build horribly unusable AJAX apps. User-centred design is technology agnostic.”

Purchase "The Stripes Book" now

Comments