It's a tool that has brought me countless joy even as I built complicated pages that require tons of functionality. It can be great for HCI (Human-computer Interaction), and the like. But like all tools, it can be overused. And misused. I know from first-hand experience.
A supervisor once sent me a memo to "remove all unnecessary AJAX". As far as I was concerned, that would entail removing just about every occurrence of AJAX. Because very little about AJAX is "necessary". Most things work fine without AJAX. AJAX just adds on certain little perks - like not needing to reload your entire page to get new information. Your application isn't going to die without it.
So here are some of the situations where you should seriously consider not using AJAX.
Having a hard time searching? |
You need your stuff to be search-friendly
Search robots trawl HTML that has been generated by web servers. AJAX bypasses the HTML generation process, filling in content in the HTML placeholders only after the HTML has already been generated by the web server. As such, search engines are only able to pick up the HTML of the pages before the AJAX-generated content has been filled in.If, for example, you're running a news blog and your articles are generated by AJAX, all robots are going to pick up are the generic HTML templates that's used to house your AJAX content. Kind of like getting the donut without the jelly. Hardly ideal if you're going for Search Engine Optimization and a good web presence. Not a concern if it's an in-house web application..
The conventional way, and the newfangled way. |
The conventional way works just fine, or better
AJAX, by design, breaks up the traditional flow of the web. Back, Forward and Refresh buttons do not work in expected ways. That can be a good thing, and it can be a terrible thing. Sometimes, you need your pages to be synchronous.Let's say you have a very long article that has been broken down into 5 different pages. Being able to use the browser's Back and Forward buttons on this one, would be invaluable, but impossible if the 5 pages of content are served by AJAX. And bookmarking each page would be an exercise in futility because the bookmarks would all point to the same URL.
By the same token, you may want to avoid AJAX if your page lacks refreshable content. By "refreshable" content, I mean dynamic content that needs to be updated periodically while the user is accessing the page. This may apply to news feeds, user-posted comments and user notifications. It makes no sense to apply AJAX to a page with only a header, content body and footer. Try to avoid overkill. Remember, at some point, people are going to have to maintain the page.
The entire point is to give users what they want with a minimum of fuss.
Does stuff need to run on the older platforms? |
Backwards-compatibility is an issue
If JavaScript is disabled or very old browsers are being used, there goes your AJAX. There are, of course, times when I'm tempted to say "to hell with it" and do it anyway. But understand that you're taking a very real risk here of alienating that portion of your intended audience. If your content can be served just fine without AJAX and you really need as many people to see it as possible, go retro.A good example would be pages with content that does not need to be dynamic and isn't expected to change very often, such as a technical document.
Remember this!
Being the exciting tool that it is, developers get tempted to use AJAX just because they can. And that is usually a bad idea. There are no blanket solutions in this business - not AJAX, not nothing.
Don't overdo anything. Don't be A-JAX-ass.
T___T
T___T