The Scriptaculous/Prototype Conundrum
Mar 27, 2006 by
Andre
So you are about to code up some wicked 2.0-style AJAX-enabled web goodness. First things first: say the title to this post really fast five times.
Now, you need to decide if you will leverage the Prototype and Scriptaculous libraries (P/S hereafter) to take some of the AJAX weight of your back. If you are programming with Ruby on Rails (and you probably are, because that's the way you roll), the decision seems almost made for you: all those nifty helpers for AJAX updaters, drag and drops with callbacks, etc. etc. Rails makes it so easy, why wouldn't you go with the P/S one-two punch?
Now, you need to decide if you will leverage the Prototype and Scriptaculous libraries (P/S hereafter) to take some of the AJAX weight of your back. If you are programming with Ruby on Rails (and you probably are, because that's the way you roll), the decision seems almost made for you: all those nifty helpers for AJAX updaters, drag and drops with callbacks, etc. etc. Rails makes it so easy, why wouldn't you go with the P/S one-two punch?
Page weight, that's why. If you buy in all the way, your pages get another 139K of .js files. If you forgo the Scriptaculous effects, you're still in for 47K worth of Prototype.js.
Obviously the browser caches your .js files. If you're building a site where most users have fast connections and will stay for a while, then maybe it's nothing to worry about. But if it's a site you want a diverse set of users to visit without the overhead of the heavy script downloads, than it is an issue.
What are the other options?
- Prototype with moo.fx -- not as full-featured as the P/S combo, but significantly lighter.
- JQuery -- significantly lighter than even Prototype alone, and with some effects available. I have not tried it yet, but it looks very interesting.
- Roll your own -- pick-and-choose functions as needed from other libraries, or write as needed from scratch. This yields the optimal page weight, but requires a lot of time. Also, it makes it very difficult to leverage upgrades to the libraries, which is a big reason for using them.
- Investigate one of the many other AJAX libraries out there . . .
. . . which brings us to the real Prototype/Scriptaculous Conundrum: which AJAX lib should you spend your time learning and making an integral part of your toolkit? I find that in the process of wrapping my head around any of the toolkits, I forget details of the others pretty quickly.
In the past, I opted to roll my own. I ended up with a compact toolkit which exactly suited my needs, and which I knew inside and out (one of the advantages of writing something yourself). But I invested a lot of time which might have been better spent.
With all that in mind, some thoughts based upon my experience:
- If you are writing an INTRANET application, go with the most robust framework available (currently P/S), at the expense of page weight. You have a limited set of users, mostly likely on high-speed connections. Unless there's a requirement for remote/dialed in users, in which case the equation changes considerably – you may be better suited with something lighter-weight..
- If you are writing a public-facing internet site with a limited 2.0-savy audience, the P/S combo is also a good choice. Your users are also likely to have high-speed connections.
- If you are writing a high-profile general-audience website (say a large ecommerce project), consider going with one of the lighter-weight libraries or rolling your own. Your pages need to act more like pages and less like applications. Also, your users won't have the same expectations around 2.0-ness which might otherwise compel you to utilize some of the more advanced Scriptaculous effects.
TrackBack URL:
Listed below are links to weblogs that reference The Scriptaculous/Prototype Conundrum:
» Conundrum 2.0 from AJAXGallery.Net
An article which raises the questions of which library kit you should be using, and the consquences.Basically it comes down to your audience and how much you think they'll put up with and/or be able to handle client-side.Web 2.0 Technologies: The Scriptac [Read More]