Rise of slow AJAX applications

The current movement towards AJAX is a good thing. If it really were a movement towards AJAX. In my eyes it is rather a higher acceptance for Javascript applications. Of course, it is quite naturally in the early stages of a “hyped” technology to observe many misuses; they use AJAX just for the sake of using AJAX.

Pages get more voluminous because so much code has to be loaded to the browser (which makes the browser slow again) so you could just begin to use the application. This somehow reminds me of all the flash apps. Waiting for hours to load the page and you’ll stick to that page for half a minute. (I do have a broadband connection. Still a page with 30kb loads 10 times faster than a 300kb page).

A negative example for this is Kiko, a web calendar. It has a nice “Kiko loading” box which already hints that they are doing something wrong. All Javascript files are included via server side scripting instead of loading them via <script src=”xyz.js”> which would allow the browser to cache the file.

Kiko is just one example, there are others doing similar mistakes.

I think that the current usage of AJAX is a misuse of the browser. They are designed to render web pages (i.e. (X)HTML pages). Javascript is a bonus. Large data strucures can slow down browsers enourmously (they are still interpreting Javascript just in time).

As a conclusion I want to come up with some essential features for AJAX applications:

  • Keep it bookmarkable. Don’t load everything to one page, let users return to a certain section of your app via their bookmarks.
  • Don’t overuse AJAX. Often simple Javascript without server interaction will do. Try to reduce the server callbacks.
  • Minimize the code to be loaded. When you don’t have any other choice, consider code downloading.
  • Speed up your apps with AJAX. Use AJAX for what it was meant for: tune your existing application at points where postbacks need to reload the same page with only little change.

ajax, kiko, bookmark, code downloading, speed

Bloated Ajax Applications Due to Libraries

When Ajax began to rise, there was quite a movement towards the prototype javascript library. This was also pushed by the great Ruby on Rails. Then came the visual effects of script.aculo.us. They look great, they really do. But for what price? Lots of KB of code.

alex@www:~/scriptaculous/$ du *.js -ch --apparent-size
23K controls.js
18K dragdrop.js
21K effects.js
28K prototype.js
899 scriptaculous.js
12K unittest.js
8.7K util.js
109K total

This is unacceptable for just a library. Most of these KB’s have to be downloaded and do not provide any functionality per-se. Broadband is not an argument here. To load or not to load 100kb is relevant.

I therefor really like the Sack of Ajax. It takes only about 4K:

alex@www:~/sack/$ du *.js -ch --apparent-size
3.9K tw-sack.js
3.9K total

Now this does not give us all the script.aculo.us stuff. For that case I suggest to just reuse the relevant parts of it. Just let the user download what you really use. Maybe one day we will see a reduced script.aculo.us. Or an alternative using Sack.

UPDATE: I now recommend to use protoype.js again, in a reduced version just for AJAX.

ajax, sack of ajax, prototype, bloated