September 21st, 2006

Frontforge has a set of Ajax evaluation criteria that look, at first glance, quite good until you drill down into each item. Since the page is created in such a way that I can't right-mouse button copy text in order to make quotes (and breaks in Safari to boot), you'll have to read each section first before reading my notes.

Taking each in turn:

#1 Back button, history, and bookmarks

If I create a slidehow using Ajax, according to this list I must make sure that each slide is reflected in the history and accessible via the browser back button, as well as being bookmarkable. However, one of the advantages of slideshows is that I can go through a set of photos and then hit the back button once to leave the page and return to where I started.

There is no contract with the users that history or back button or any such is 'required' in order for a web application to be successful. That's all made up. What is required is that one understands how people might use the application and then respond accordingly. So, for the slideshow, rather than try to force behavior into the browser for it to manage an arbitrarily constructed 'history', what one needs to do is understand what the users might want.

In the case of the show, being able to access a specific show 'page' using an URL that either can be bookmarked or, more likely, linked, could be the critical item. In this case, creating a 'permalink' for each page, and then assigning parameters to the URL, such as the following, would enable a person to return to one specific page.

http://somecompany.com?page=three

Then the JavaScript framework or whatever can parse the URL and load the proper page. As for having to maintain history, I would actually prefer to see history locked behind signed and sealed scripts and not easily accessible by JavaScript developers. This, then, would also include screwing around with the back button.

#2: standard and custom controls

In this one, the author states that an Ajax framework should have a good set of built-in controls to start a project and then a means to easily extend these for custom behavior. This one I do agree with: a JavaScript library (any class library, really) should include one layer that defines a basic set of behaviors, which is then used by other libraries to build more sophisticated components.

Except that this isn't what the author is saying. What he or she is saying is that a 'basic' behavior is something such as a complete packaged piece of functionality such as a drag and drop or a visual fade, while the more complex behaviors would be something such as a complete mouseover and slideshow or some such thing. Of course, when you see a complex behavior listed as something 'basic', it makes sense that customization becomes increasingly difficult. That's more a matter of incorrect abstraction than making use of something such as JavaScript's prototype property.

In my opinion, simpler components and good documentation is worth any number of increasingly sophisticated objects.

#3: single page interface

Being able to edit a page's contents in page, such as that implemented at Flickr is what the author is talking about here. I gather there's now a formal name for this: single-page interface. That's like Jesse James Garret's use of Ajax to describe a set of already existing technologies–if you speak with enough authority, anyone can name anything.

I hereby call this a weblog. Oh, wait a sec…

But the premise of the author's assumption goes far beyond this. According to the writing, a page should be split into components and then each should be loaded at runtime and formed into a cohesive whole through JavaScript. So a five step form starts by loading the first step and then the additional steps are loaded as the person is working the first.

My response is: why? Why do I need to use JavaScript to access the components that we already know are going to be loaded? I can see using something such as the accordion effect (collapsed sections that hide specific pieces of the form until expanded, such as that being used with Wordpress), but it makes no sense to somehow load these individually, starting with the first part and then use Ajax calls to the server to load the rest.

If what's loaded is altered by what the person has entered, such as providing a list of cities when a state is picked, then it makes sense. But if it's static content, or content ahead of time, we should let the web server do its job uncomplicated by client-side overriding of basic behavior.

If time is the issue (the author doesn't really state a good argument for this, but lets assume time is the issue), then perhaps if we didn't build such over-engineered Ajax libraries, page loading times wouldn't be such a problem.

Hiding and displaying components of the form and allowing in-page editing does make sense. But this loading by piecemeal using JavaScript? No.

#4: productivitiy and maintainability

This is the one that drove me to write this post. This was the 'money' item for me.

According to the author, I gather that it's difficult to find qualified Ajax developers, and it's an unwieldy burden to get existing developers (page or server-side) up to speed to be able to use all of this Ajaxian goodness. There's even an OpenAjax movement afoot to …to promote Ajax interoperability, standards and education in order to accelerate the global adoption of Ajax. (And it doesn't hurt one's business to put their membership in this effort into their About page, either. Point of fact to the effort: Ajax does not 'stand' for anything–it's not an acronym. It's just a simple term that Garrett picked.)

Instead of forcing JavaScript on folks, a better approach (according to the author) is to use existing CSS and HTML elements. How? A couple of different ways.

One way is for the script to take all elements of a certain type and add functionality to each, such as to add validation techniques for each form element (triggered by some behavior such as loss of focus when the person keys away from the field). This isn't a bad approach at all, though there is usually some JavaScript involved as the person has to attach some information about how a field is to be validated or some such thing. Still, it's nice not to have to worry about attaching event handlers and capturing the events and processing the data and so on.

However, according to 'declarative' Ajax, this additional information isn't provided into JavaScript. Instead of using script to provide information to the program (no matter how simply this could be done), the Ajax framework developers have 'extended' HTML elements to include new attributes. With this, the poor Ajax-deprived page designer and developer need never get their fingers dirty by actually touching JavaScript.

Sounds good, one problem: these methods 'break' the page, leaving invalid HTML in their wake.

You don't have to take my word for it. This page discusses the "right way to do Ajax is Declaratively". The page validates, but then it's not using any of the Ajax frameworks. One of the frameworks mentioned Hijax also validates, because it's using standard HTML elements (list items) and the class attribute (standard for all HTML elements), in order to maintain its effects. The other libraries, such as hInclude and FormFaces, do not validate. Why not? Because they're using non-standard attributes on the HTML elements.

We've spent over a decade finally getting the cruft out of pages. I'm not going to be sanguine about blithly putting more cruft back into the pages because we want a 'cool' effect. (For more on this, I recommend Roger Johansson's Why Standards Still Matter.)

Leaving aside my concerns about how much we're overloading the 'class' attribute, deliberately introducing invalid HTML is not a mark of progress. Leaving aside how this could impact on user agents such as text-to-speech browsers, this approach seems to assume that everyone who wants to incorporate Ajax outside of a select few intelligent enough to understand its complexities must be protected from the 'working' bits. That's arrogant in the extreme because there's nothing overly complex at all about Ajax. It's actually based on some of the simplest developing technologies there are. Well, other than when such are obfuscated in order to puff up the concept.

Moving on to the rest of the Ajax must haves…

#5: client server

Well, this one is like being agin sin. Client server is good! OK, we got that one.

There's little to quibble with on this item. The front end work separated from the back; hide cross-browser differences; communicate with the server using XML (though I think this one can be negotiable). I am concerned with a growing interest in making all aspects of a web application into Ajax initiated function calls, rather than using server-side templates and such; other than that, I can agree with this point.

#6: XPath targetting

My god how have we managed to get by now, with having to use JavaScript functions such as document.getElementById. If I'm reading this one correctly, it would seem that Ajax frameworks have to take the DOM and convert it into XPath notation before we can even begin to work with a web page.

There is something to be said for being able to access a page element using an XPath notation rather than having to use the DOM's getChildNodes, but the examples given don't demonstrate the power of such operation, and I'm not sure this is as essential as the author makes it out to be.

#7: comprehensive event model

Luckily, I found I can copy; I just have to use the Edit menu copy, rather than right mouse button. The author writes:

Next-generation Ajax frameworks finally make it possible to put the presentation layer into the browser client where it belongs. This opens up a huge business opportunity to migrate strategic desktop applications to the web where they can deliver value to partners, customers, and remote employees. To do this, it must be possible to define mouse actions and key combinations that trigger events.

Next generation Ajax frameworks may allow this, but I don't see a mad dash to put desktop applications on the web. This isn't Oz, and clicking our Ruby slippers together, saying, "There's no place like the web…there's no place like the web" isn't going to make this happen.

I do agree with a standard set of event handlers, and making sure that each library chains its functionality on to an event so that it doesn't bump another library's (or the web page developer's), but I don't think this means then that we can move Adobe Photoshop on to the web. I don't think this is something that users are demanding.

As for making a set of 'custom' events, such as NextMonth for calendars, this totally abrogates much of the concept of abstration by taking a general event (such as a mouse click) and blurring the lines between it and a business event (NextMonth). This not only adds to the complexity of the frameworks, it adds to the size of the code, as well as the points of breakage any time a new browser is released (or a new library included in the application).

What is really needed is a basic understanding of how event handlers are attached to objects, ensuring that no one library impacts adversely on another library or on the web developer's efforts. That and a simplified way of attaching events to objects is nice. More than that is an example of a developer with too much time on their hands.

#8: state and observer pattern

It always amazes me to see even the most simple concepts obscured whenever the term 'Ajax' is involved.

This last item has some good points but they're heavily obscured with using design pattern terminology such as "Observer pattern" and so on. Yes, I know that the use of such is to make communication easier so that when a person writes, "Observer pattern" we understand what they mean without them going into details. But then this means that the reader has to stop reading, go to the pattern page, read the pattern, get understanding, return, and then try to decipher is what the person is writing is what was meant by the pattern and so on.

I understand what is meant by 'observer pattern', and I can agree with the idea that wouldn't it be nice to attach a behavior (register) to a form button that allows it to enable itself when certain form fields are completed. The whole thing is based on storing information about the 'state' of the object, which as the author of this Ajax framework must-haves notes, isn't part of basic JavaScript behavior.

Except that it is. Within the same page, information about state of element is stored all the time, and I fail to see how there needs to be a formalized mechanism in place to facilitate this. As for storing state between pages, again mechanisms are in place through cookies, server-side storage and so on.

As for observer/registration, is it that we want all blur events triggered in the page to be funneled through an event handler for the form submit button that checks to see if it can now enable itself? Or blur events for the target fields? That's doable, but seems overly process intensive. I would think a better approach would be to have the form submit button enabled, and then when the form is submitted, use Ajax (JavaScript) to test if required fields are filled in and then direct the person's attention to what's missing. Then event handling is simplified and the only time the process is invoked is when the form is submitted, not when each field is filled in.

In other words, what may work well with an application built with VB.NET may not work well, or never work well, within a browser and what we should not do is coerce functionality from one development environment onto another.

That's they key for much of these 'essential' items for an Ajax framework: many add unecessarily to the complexity of the libraries, as well as their size, the number of points where a break can occur, and the likelihood of failure when more than one library is used or a new browser version is released.

In web development, there's one important rule: less is more.

Thanks to Ajaxian for pointer to this list. In the interests of disclosure, note that I am writing a book, Adding Ajax, whereby I demonstrate that any web application developer familiar with basic JavaScript can add Ajax benefits and effects to their existing web applications. As such, I've violated the premise behind #4 by assuming that just anyone can become an 'Ajax' developer.

Comments
1

Ah, reading this is like a breath of fresh air. I'm glad I'm not the only one who thinks that the list you mentioned is full overly-technical complex terms for what are basically simple ideas. I can't but feel that the reason why Backbase would be going out of their way to try to convince people that Ajax is some kind of rocket science is so that they can hawk their particular library/framework to developers with a pat on the head as they say "there, there, don't you go worrying your little head about that nasty complicated Ajax stuff."

One small point: Hijax isn't a library or a framework, it's just an idea (a laughably simple one, really).

I'm in complete agreement with the premise for your book. It sounds like it will be great. I can't wait to get my hands on a copy.

2

While there are certainly horrible uses of HTML extensions, there are also times when using them is the right thing to do — e.g., when you need to introduce genuinely new semantics.

HInclude was one of those; after talking to a few different people, I came to the conclusion that overloading a class wasn't the right thing to do. A new element indicates that there are new semantics, and the fallback mode for implementations that don't understand works well, thanks to the advice that HTML gives.

Does it validate? No. Do I care? Not terribly; while validation is good for telling you how to know how to use a vocabulary that the validator understands, saying that anything outside of that scope isn't allowed is going too far. If we don't allow any new extensions in HTML, we'll be stuck with procedural JavaScript on the Web for a long, long time.

(And yes, I'm aware of Modularization in XHTML; until it's widely implemented and comprehensible to average Web developers, I'm not too interested).

Cheers,

3
Kevin Marks - 2:36 pm 9/21/2006

Shelley, I agree with you about making valid HTML, which is why using javascript 'decorator' scripts is such a good idea. If the javascript library looks for certain classes to transform, and uses valid fallback markup, that is a good way to proceed. Your dock-emulator example before would benefit from that, falling back to a list for javascript-less browsers (not a criticism of you, more of Dojo for it's non-HTML extensions).
What are your concerns about overloading class? As class can have a space-separated list of classes, this is a very flexible way to allow enhanced markup, which is why microformats make such use of it.
By letting a element have multiple classes, you can use javascript extensions as mixins, just as you can with CSS. Similarly, you can use the containment possibilities of classes to effectively pass the contained elements to the javascript decorator.

4
James Kew - 2:58 pm 9/21/2006

A lot to chew on here, and most of it out of my depth. But I wouldn't throw away hostory so easily:

There is no contract with the users that history or back button or any such is ‘required’ in order for a web application to be successful.

As a user, I'd argue that, although I don't have a contract, I do have a fairly strong expectation that the back (and forward) button behaves in a reasonable and consistent way — and that way is usually "how the rest of the web works".

Breaking that expectation is likely to annoy me, even if there are good reasons for it. To take your slideshow example: yes, back to back out of the entire slideshow makes a lot of sense at the intellectual level — I went to look at some media, and now I'm done with it.

But at the reptilian level, I can pretty much guarantee that at some point I'm likely to reflexively press the Back button to back up to a slide that took my fancy. Dumping me out of the entire show is going to be annoying; and I'll be even more annoyed when I press Forward to go back in and find that I've lost my place in the slideshow and am back at the first slide.

Changing the rules at this point is changing 10+ years of mental models and habits: it's tough and there'd better be a damn good reason for it.

The hubris in the quote cited at the article — "teach users not to use the Back button" — resonates hard with me. I've used a number of online banking sites over the years which take this attitude: having decided that the Back button presents a security risk, they punish me for using it by throwing up a chastising message and forcing me back to a login page. Goddamnit, how hostile!

But now my knee is well and truly jerked,

What is required is that one understands how people might use the application and then respond accordingly.

I strongly suspect that "how I use the application" depends a lot on "how I perceive the application". If it feels like a web page, I'm likely to try to use it like a web page: hence my frustrating online banking experiences. I followed a link like I would on a web page; but when I try to go back, oops, wrong model.

Conversely, Google Spreadsheets feels like a desktop app, so that's how I use it. I couldn't tell you what it does in response to the Back button because I've never had the impulse to press it.

I think there's a simple duck test here: if you look like a web page, you should quack like one.

5
Shelley - 5:30 pm 9/21/2006

Jeremy, good catch on Hijax. It's a good idea and example.

Mark, we've had procedural JavaScript for years now, and we've managed to create some pretty nice stuff. But extended HTML is one thing that got us into problems in years past, so I hate to see us going that direction again.

Kevin, not sure how the use of class would have allowed me to use the Dojo library extension for fisheye and still allowed the page to validate? In this case, the library expected the custom attributes. I suppose I could have used a class and used this to designate which elements to add the custom attributes to–but seems even more complicated.

Overloading class: this is a way of adding keywords to an element, but not necessarily a way of adding keyword=value to an element.

Would be interested in yours and Mark's response to each other's comments, too.

James, good point on looking like a web page and acting as such. But something like a slideshow that has a next/back arrow is pretty common, and most folks know this is 'content in a page'. Flickr's slideshow is an example of this. I don't think people expect this to have a 'back' button for each slide. I do think that people would like to go to each individual picture, or perhaps have the slideshow remember where they were last time they visited the page.

Now, if I create what looks like five separate web pages, and traverse through them, but they're all actually the same web page changed with each click, I would expect to have 'back' button behavior. But my Ajax effects rarely try to emulate completely separate page — I would rather just load a new page.

6
Kevin Marks - 8:17 pm 9/21/2006

Well, HInclude looks like a bad way of reimplementing JAH to me. Or indeed iframes. JAH lets you include an HTML fragment, iFrames a page.
Class lets you mark an element for special treatment. How to do keyword=value depends on whether you want the keywords and values human-readable or not. If you want keywords and values human-readable, use <dl>. If you just want values human-readable use a span with a class. Of course, there may be more semantic elements in HTML you can use for any given case. Have a look at the microformats examples for pre-existing thought on this.
Working within the constraints of HTML is a bit more work, but I agree that it is worth it.

7

Extended HTML elements like BLINK got us into trouble because vendors used their market share to push their own tags into the language without coordination. Comparing that with adding new elements that are supported by a JavaScript implementation is totally apples and oranges.

Compared to the continuing security and interoperabilty nightmare that is JavaScript, that was a picnic. Yes, there's nice stuff out there, but it's pretty steeply taxed.

With HInclude, I wanted to show that there's a way to introduce new functionality with JS, but allow the implementation to be moved into the client later, if warranted. This approach definitely isn't for everything, but I think it has a place.

Let's look at the practical trade-offs, rather than wave hands about standards goodness. By defining an element, HInclude:

1) Lost the ability to be called valid by HTML validators. But, if you're willing to ignore two or three errors, you can still find other problems on your page.

2) Gained the possibility of being declarative markup directly supported by the browser if enough people want it, and vendors listen.

If I had chosen to do it as a microformat, those aspects would be roughly reversed. It's a judgement call as to which of them is more valuable.

HOWEVER, what HInclude does isn't microformats are for; when you're adding new content from an external source to the page at load time, you're doing something fundamentally different than saying "use this style here" or "this is an address."

Consider - if we didn't yet have an IMG element, would your recommendation be to add support for it as a special class attribute, or by overloading an A tag with a javascript URI?

8
Kevin Marks - 2:46 pm 9/22/2006

There is an element for it, it's <iframe>. If you don't want to do it that way, you can load a javascript that does a document.write() . If you don't want to do it that way, you can use the JAH technique. All of these work and are valid HTML.
So your "I must invent a new element for this 'cos it is so innovative and cool" is wrong on all counts.

9

Kevin, I don't know how to refute such a comprehensive and well-reasoned argument, so I'll just leave it there.

Cheers,

10
Shelley - 4:29 pm 9/23/2006

Jumping back into this thread…

Kevin, using something like dl makes no sense, because you're mixing your metadata and your data. There really is no graceful way of doing key=value pairs with microformats. That's not a 'bad', it's just that's not their space.

Mark, I must confess with the modern browsers, I don't have many interoperability problems. A few challenges now and then, but that's about it. Security is always an issue, but I never push the sandbox and watch my user input. As long as the browsers fix their flaws, that will have to do.

I'm not sure how either of these have anything to do with hInclude. You're emulating server-side includes using JavaScript, and I can't see what this buys, Mark. What is the need that this fulfills that would justify breaking web pages?

11
Kevin Marks - 9:13 pm 9/23/2006

Shelley, that's why talking about this in the abstract is a mistake. Lets pick a concrete example and consider how to do it - we can revisit the Dock menu thingy if you like, though that was a rather trivial example.
What is data and what is metadata depends on the content and the context. If you have a series of key/value pairs where both the keys and values make sense in text to humans (say, a credits list for a film) <dl> is fine - this is part of the XOXO spec.
If you have a case where the values are human readable, but the keys are for machines, use the "class on container" technique - see hCard for examples of this.
If you have a case where neither key or value makes sense to the humans, only the script, use JSON (ie express them in <script>)
That leaves the case where the keys make sense and the values don't - the <abbr> design pattern could work there.

12
Shelley - 10:25 pm 9/23/2006

Kevin, you say that was a 'trivial' example, but you're not telling me how microformats is a better way than what I used to convert the Dojo fisheye effect into valid page content.

Perhaps you can do an example, link it here. That's usually worth a dozen comments.

13

I'm happy to see you arguing against the continued obfuscation of both AJAX and HTML. I do think the class attribute was intentionally designed to classify HTML nodes for processing by user agents via JavaScript, but certainly there's room for unnecessary complication there by putting information in the class attribute that isn't really a class.

If you're all going to continue referring to the Dojo dock thing in your comments, one of you might want to link to it. I only have a vague recollection of what that was, and I'm sure anyone new here is completely lost.

14
Shelley - 9:12 am 9/25/2006

Oops, though I had Scott. Here tis.

15
Scott - 3:46 pm 9/25/2006

As for observer/registration, is it that we want all blur events triggered in the page to be funneled through an event handler for the form submit button that checks to see if it can now enable itself? Or blur events for the target fields? That’s doable, but seems overly process intensive. I would think a better approach would be to have the form submit button enabled, and then when the form is submitted, use Ajax (JavaScript) to test if required fields are filled in and then direct the person’s attention to what’s missing. Then event handling is simplified and the only time the process is invoked is when the form is submitted, not when each field is filled in.

There are specific cases, such as an autocomplete text box or chained select boxes, where firing an event when the value of the individual element is changed is the proper behaviour and the observer pattern is useful. I have a specific instance of both in an application I'm currently working on. Our data abstractors have to enter the drugs that a patient is currently on. There are too many drugs to be listed in a single select box, so we created an autocomplete textbox (a'la Google Suggest). This allows our users to enter in new drugs that are not in the system yet, but still allows them to pick the correct drug from our predefined list.

Since certain drugs are measured only in specific units, we can chain the "units" select box to the drug value textbox. When a certain drug is entered into the text box, the correct units will be automatically selected for the user. When you are entering thousands of drugs, little steps end up saving a lot of time. The observer pattern is at the heart of most client-side data entry applications and it makes sense to transition it to web applications.

However, automatically filtering the onBlur event for all elements on a page just to check for nulls seems a bit silly. It seems best to do it at submit time as you said.

16

Shelley, see the summary of my XTech talk for the use case. In a nutshell, it's the evolution of what we were trying to do with ESI at Akamai; doing it in the intermediary was the best we could offer then, but the browser is the right place for it.

You say "breaking Web pages," but it's really just breaking validation, which is a very different thing. I think validation has a place, but it shouldn't have the last word in the evolution of the Web. YMMV.

17
Shelley - 8:13 am 9/29/2006

Making sure a page is valid is just one step in making sure that the page performs as expected–more or less–in all browsers and in all circumstances, tomorrow as well as today. It's not a perfect process, and even when a page validates it may not be 100% valid. But it's a start.

There might be cases where both accessibility and valid markup are sacrificed in order to provide some experience, such as creating a Word tool online. No loss, really, because there are other options for people. But if we begin a practice of not worrying about this 'little' bit of invalid markup, or that little bit of non-standard JS, and so on, then next thing you know, we're back in the old days of posting notes on our sites that people have to use Firefox 2.13 to read it (and have this turned on, and cookies enabled, and so on). This just when we were finally starting to see relatively consistent pages across platforms and browsers.

The web started out sloppy and chaotic and then began to grow up. Do you see it now entering an age of early senility, where it again becomes sloppy and chaotic?

18

Shelley - your comment hits the heart of the matter; the question is whether you consider the Web grown up, or still in need of maturation.

I absolutely agree that pages should be designed for the long term, and validation is a valuable way to get to that goal. My only objection to it is when validation is used to argue against extensions that might, in the long term, make the Web more mature, functional and declarative.

I know that most people consider HTML done, so this isn't a mainstream view. I'll try to write more on my blog soon.

Thanks to all those who have contributed to the discussion. Comments are now closed, but you can contact the author of the post directly.