AJAX is evil
February 11th, 2006
One of the talks whilst I was at the UK PHP Conference was on AJAX, and its downfalls. The talk was done by Harry Fuecks, someone whose opinion is respected within the online community. I've always been a bit wary of 'new' technologies when they surface, and the mad rush to implement them as they are 'cool'. Ajax is not exceptionally new. Internet Explorer was the first browser to implement the XMLHttpRequest protocol as an ActiveX object, way back in IE 5 circa 1999. However, its only been the recent use by certain big sites such a Google and Amazon that have made it more mainstream in the rush to implement it.
Is it worth it?
The problem with utilising new technologies, is that its used, in most cases, for its *wow* factor, rather than it actually providing something useful. Google Suggest is prime example - it may have that *wow* factor, but who actually uses on a daily basis? I surely don't, and in a conference with around 250 delegates, no one raised their hand to say they were using it - or had the balls to admit it.
The issues
The fundamentals of AJAX / XHR are this:
- A client side XMLHttpRequest object is initiated based upon a user action such as onBlur etc
- This forms the HTTP request, which connects to your server side application (PHP, ASP, JSP, etc)
- The server application forms a response (text or xml) which is sent back to the client via XHR where the response is parsed and presented to the user
- This is all done without refreshing the user's browser page - that is, its done in the background, usually without the user knowing so.
There are a few issues with this. Notably, one problem is that if the user hits back, and expects the last action to be reversed, this won't happen. Furthermore, if you base your site largely on AJAX changes, and a user bookmarks your page, there can be a difference in what the user *thinks* they are bookmarking, over what they actually are. You may as well revert to frames or stick your site in flash.
Latency
Harry brought up a few good points regarding AJAX's disadvantages. The biggest one in my opinion is that of latency. I'll try and summarise what Harry meant by this. Packets of data sent from your computer over the internet to the receiving server are subject to a certain time delay due to the network of routers and fibre connections the data passes. Lets assume your site is sending several packets to the server from the client end via AJAX. If the packets are not received in the order they are sent, you can get some very unexpected behaviour. This latency can also be accentuated if your ISP routes your conenction via multiple proxy servers. AOL is renowned for this, and NTL in the UK is also guilty as charged. Harry has a fantastic flash demonstration of this online which shows how the latency can affect AJAX to a point where it is unusable.
Synchronous and Asynchronous
XMLHttpRequest can be instructed to send the request either in a synchronous or asynchronous manner. A synchronous request will wait for the server's response before continuing with anything else. Whilst this may seem like a good idea, this is exceptionally bad. Waiting for a response from the server can take a few milliseconds, or several seconds, or even minutes on a exceptionally busy server. Meanwhile, the browser is still waiting for that response. Harry shows again what happens next.
So surely the answer is to send the requests in an asynchronous manner. In this method, the request is sent and the browser doesn't wait for a response. Hence, it isn't kept waiting. The issue here is that packets that don't quite make it to the server mean that the intended action doesn't occur.
Summary
The sudden rush with which AJAX has suddenly blossomed may indicate to some people that its useable and faultless. Looking back over time, we can see this is merely a cyclical repetition of history, and whilst time takes its due course, its usability and function will become more apparent.
Some interesting links:
- How AJAX Works
- Synchronous requests are bad
- Harry Fuecks' talk from the PHP conference [PDF]
- Latency and Bandwidth
Add to del.icio.us
Digg this
Technorati
Related Posts:
10 Comments Add your own
1. civ | February 11th, 2006 at 4:12 pm
That video has changed how I think about AJAX.
I'm going to make one that proves that AJAX sucks, because it stops working all togehter when I pull out my network cable.
2. Garf | February 13th, 2006 at 4:49 pm
AJAX rocks, removes all sorts of stains, never had a problem using it, even if my interweb goes down
3. Kev | February 15th, 2006 at 10:27 pm
The latency issue is a good point and one I hadn't considered. The rest…its not AJAX thats evil (just like Flash isn't evil) but they can be implemented so badly those implementations become evil.
I think AJAX has its use in a controlled environment - I use it a lot on some intranet based apps the company I work for develop because we can determine the environment but live on the web? It has to be approached very carefully.
4. Khalid | February 16th, 2006 at 10:32 am
Aye, the 'Ajax is Evil' title was there to provoke some sort of response from the readership.
Hopefully that will come true soon!
5. Nate K | February 24th, 2006 at 3:48 pm
I would agree with Kev on this one. I dont consider it evil, it is a tool, just like flash and other technologies. However, when implemented poorly it reflects poorly on the technology. Just because a tool is there doesn't always mean it SHOULD be used - but it is nice to know we have technology like this at our fingertips.
I think it has to do with the rush of everyone having the next big idea, and when they look to the internet they think they HAVE to use these things in order to be successful or 'cool'.
Good post…
6. Jared Kim’s Weblog &hellip | February 28th, 2006 at 8:43 am
[…] I stumbled upon a great article titled 'Ajax is Evil'. […]
7. Umanath | November 29th, 2006 at 3:09 pm
Wrong implementation of all technoliges will yield wrong results. These are simple issue, i think, which can be easily overcome by growing bandwidth of n/ws and numbering the request.
8. Isuru Eranda | January 3rd, 2007 at 4:54 pm
umbala maha wesige puththu….
umbala okkotama pissu
9. David | January 15th, 2007 at 3:01 am
Deep.
10. My Family Blog » Bl&hellip | April 23rd, 2007 at 7:08 pm
[…] via http://www.jellyandcustard.com/2006/02/11/ajax-is-evil/ […]
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed