Showing posts with label XHR. Show all posts
Showing posts with label XHR. Show all posts

November 18, 2007

AxsJAX vs. Hijax


Google decided to Open Source yet another tool: a Javascript framework called AxsJAX, which aims to "add accessibility to AJAX-powered web apps". AxsJAX is already used in a couple of Google Apps, and is a set of Javascript tools that add accessibility tags to your AJAX webapp. This means that AxsJAX, spelled "AcessibleJAX" (to rhyme with AJAX), is only used if you have a recent web browser that has Javascript enabled and implements the drafts of W3C-ARIA, which, in other words, isn't an acessible framework at all. If you take into consideration the W3C Accessibility guidelines, you'll quickly see that depending on some yet-to-be standards (ARIA) or even in Javascript isn't being Accessible. Yes, you can add AxsJAX to your AJAX-powered webapp, but you must take into account that it will not make your webapp accessible... As a matter of fact I think it would be nice to have webapps using it, but on already accessible webapps.

Now, there's this silly idea that it's too hard to make an AJAX-powered webapp accessible. Developers talk about painful code to allow graceful degradation, and some are even crazy enough to actually prefer mantaining two webapps: one AJAX-powered and other AJAX-less. What's really wrong about this scenario is that it's pretty easy to design accessible websites, even AJAX-powered. Welcome to the world of Hijax.

Hijax (which is nothing more than a way to use AJAX) is just the way to design AJAX-powered websites. The steps are pretty simple:
  • Design your webapp well

  • Add all the AJAX you want by hijacking the requests


Now the thing is, what is "design your webapp well"? Welcome to the wonderful world of standards. You know, all those things that people hope to comply with without really trying? If you first understand standards, their design and purpose, you'll see that's really the easiest way to do things. On the web, the trick is simple: you have
  • the data layer (HTML)

  • the presentation layer (CSS)

  • the interaction layer (Javascript)


Now, what standards teach you is that in HTML you should put all your data, and nothing more than that; in your CSS files the presentation layer and nothing more than that; in your Javascript all of your interaction layer and nothing more than that. Remember allways to avoid some mistakes: an anchor belongs to the data layer and not to the interaction layer, so doing stuff like <a href="javascript:"> is just shooting yourself on the foot. Now, if you have this scenario, you have your website (still without AJAX) and you can do all the funny stuff you like to do with Javascript. The good thing about this scenario is that if you disable the Javascript (or if you use a Javascript-less browser) all the blings, bells and whistles disappear, but all the data is there, and presented the way you design it to. Now, if you go one more layer and disable your CSS (or if you're using a web browser without CSS functionalities) you have all your data there (again), just as it should be, only without that stylish presentation you wanted to (which is pretty but useless to someone blind, anyway).

So, the thumb rule is simple: build your app as progressive enhancement, 'cause progressive enhancement automaticly guarantees graceful degradation.

Now, let's add AJAX (or the XHR component of it) into the equation. Most developers agree with all I've said until now: the need of a clear separation between HTML, CSS and Javascript, specially if you're talking about CSS's or DOM scripting. But when we talk about AJAX... they suddenly cast it aside. The problem is, basicly, that you're with the wrong mindset. Instead of thinking that AJAX is just a way to update parts of a page without refreshing, or, in the other hand, you think that AJAX is the spetacular awsome cool new thing that lets you update parts of a page without refreshing, you should look at AJAX as this new way of talking with the server asyncronously and deal with the page accordingly. Leave that "it's not a page, it's an app" thing, the app is what you built, but what you're serving is a page... even if it dynamicly changes itself over time (thanks to AJAX or not).

But I still didn't explain the Hijax part: how to add AJAX to the equation. Well, it's pretty simple indeed: just pick your non-AJAX pages, with links and forms that do requests, and just use JavaScript to intercept those requests and transform them into XHR.

This isn't meant to be an in-depht post about Hijax, more like "why you shouldn't be that excited with AxsJAX" than everything else. Anyway, if you liked the concept, just read Jeremy Keith's "DOM Scripting Blog" [1].

[1] - http://domscripting.com/blog/

May 18, 2007

Is Web 2.0 with usability or not?

BBC quotes Jakob Nielsen, while he says, basicly, that Web 2.0 is with a creepy lack of usability. People are more interested in doing fancy things than actualy making them work well. And... Not only I agree with him, but also am having this discussion with several people in the Web 2.0 world for more than two years. Of course that telling this also pisses a lot of people, and we got a R/WW post saying basicly, that none of that is true, and that Web 2.0 has a lot of usability. I'm sorry, I'm not going to use this space to bash anyone, to talk about who's right and wrong or doing publicity to 37signals. I'm just going to pick some examples to show what I mean with lack of usability.

  1. Have you ever tried to post a comment in TechCrunch using Opera Mini? Well, you can't...
  2. ...which reminds me the whole issue of "mobile versions" and "mobile portals". When you need to do a web version of your web application to run in some browsers (mobile or not), you sure usability problems. Remember, a mobile device is also a computer with an web browser.
  3. YouTube was a given example of usability by R/WW. Excuse me? IMHO the only way you can use YouTube in any Operating System besides Windows, Mac OS, Linux and Solaris (like any BSD, for instance) is by downloading the video (using something like youtube-dl or a GreaseMonkey script), since it heavily depends on Adobe Flash, which licence does not permit its use in any Operating System other than those refered above;
  4. XHR. You know? XMLHttpRequest, that thingie most use in an AJAX implementation. While I think there are great things that are achieved with this, XHR is still NOT a standard (see status and help changing it), and so several web browsers does not support it. Using it is taking usability off your web application.
  5. Another example of bad usability is taken from an example of "good usability" given on R/WW: NetVibes. You say they have great usability, but their website says:
    We currently support Mozilla Firefox 1+, Microsoft Internet Explorer 6 and 7, Opera 9.02, Safari 2+.
    I'm sorry, but if you only support some web browers, then you do not have usability.
Now, I could be hours ranting about this, but I think that it's kind of useless. People are still exited with Web 2.0, so excited that they don't really care. And while they don't care, you can tell them whatever that they won't listen to you.

If you're a Web 2.0 developer and really care about usability, please, PLEASE, prove me wrong. I would love to see, for instance, more people working with W3C.