A Look At AJAX: Pros and Cons

After taking a look at what AJAX is last week, this week I'm taking a look at the pros and cons of using it in web design. Like any tool, it has its strenghts and weaknesses, and it's important to understand those to better utilze its functionality.

PROS

  • Update Only What You Need To On A Page - Take the poll on the right as an example. Currently, when a vote is submitted, a whole new page is loaded from the server into the browser. However, if I were to implement the poll using AJAX, I could have only the poll section of the page reload when a vote is cast.
  • Save Server Processing and Bandwitdth - If you've got a lot of pages where only a small portion of the page needs to be changed, then implementing AJAX can cut down on the number and size of calls to the server.
  • Separation of Data From Layout and Style - Using AJAX allows you to keep the data separate from layout and style by only loading the data that needs loaded and maintaining the main layout and styles already defined by the initial page.

CONS

  • Not All Users Have JavaScript Enabled - For security reasons, a percentage of users have blocked JavaScripts from running, so these users won't see AJAX functionality. This can be accounted for in your code in terms of site functionality, but you won't get the same performance benefits with these users.
  • Not All Users Have The Same Version of JavaScript Installed - So, any bleeding edge functionality my error out on some computers. This may result in the need for more testing on different versions of JavaScript available in different browsers to make sure they all work as expected.
  • AJAX Can Break Site Pageflow - AJAX functionality breaks the use of the back button in most browsers, so any segment of your page you implement it on needs to have a way to get back to if there is any need to users to do so.
  • Most Search Engines Can't Reach AJAX Content - Since search engines don't typically, enable JavaScript support most search engines won't be able to reach AJAX enabled content. In order to make sure that this content can still be indexed, the equivalent data will need to be available at a public URL.

As you can see, there are certainly some cases that make better choices for AJAX content, and some where implementing AJAX can be more trouble than it is worth. Take the time to decide how you wante to use AJAX on your site to determine if it is the best choice for your site.

Next week, we'll start taking a look at how to implement basic AJAX functionality on a site. Be sure to swing by then!

Comments
Robert Evans's Gravatar A couple of corrections:

1. JavaScript does not use the JRE - Java Runtime Environment. JRE is for Java, not JavaScript. These are two completely different languages.

2. The separation of data, layout, and style is really a misunderstanding, as you've stated it. AJAX itself isn't what keeps your content separated from your style and layout. 

What I think what you meant to talk about was Behaviour, Content, and Style - JavaScript, XHTML, and CSS respectively. 

AJAX on it's own doesn't create this separation or even aid in it. It is just another tool for delivering content in a "cool" way.

3. The same version of JavaScript depends on the browser one is using. JavaScript is shipped as part of what is browser functionality. 

There is no reason why anyone should be using, let's say features from JavaScript 1.9, in any production applications or websites. The reason being, not all browsers support this version of JavaScript as it has not been formally released as a stable version.

It is always best to stick with what is widely available. 

4. There is no search engine spider (not google, yahoo, or msn - the 3 main search engines you should care about), that I know of, that will browse content that is unavailable, without the use of AJAX. 


# Posted By Robert Evans | 9/18/07 9:14 PM
Greg Nilsen's Gravatar

Hey Robert, thanks for the feedback.

With 1 and 3, you're right that I made a mistake when putting the article together. Guess I need to work on my proofreading and fact checking.4

With point 2, I wasn't intending to suggest that AJAX was a means to create the separation between content and style. It's just that AJAX pretty much forces to you make this separation in order for it to function optimally.

And for point 4, I'm pretty sure that's the point I'm making: that if a page is only loaded up through AJAX, then the major search engines will not be able to index it.

Thanks again for you input!

# Posted By Greg Nilsen | 9/22/07 7:14 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact If Jesus Had A Website