22 March 2007

Not another library!

Today I bumped into FrogJS. It’s another photo gallery ‘unobtrusive Javascript’ library, which can be used by people to make a Javascript driven animated photo gallery on their pages. My question is simple. Do we really need another one?

The whole list

There are enough libraries out in the field today. Prototype being the more famous and widely used one. Then there are the other players like mootools, SimpleJS and jQuery. These extend Javascript as a language. Individual libraries which add effects and other bling bling to your pages include moo.fx, which uses mootools as it’s base and script.aculo.us with Prototype for it’s base. Then for picture management there is the very famous Lightbox JS with Prototype as it’s base, and script.aculo.us for effects, and now FrogJS using the same. Phew! See what I mean?

It is not a question of which one is better, or faster, or smaller, or easier. It’s based on what ‘use’ you have of a library. There are many (and I emphasize) things in Prototype that go completely unused by people, but they still prefer to use it because it has a ‘few’ functions that help them get the job done faster. It makes more sense to just copy them out, or write your own (like I do). Otherwise, take time to analyse and learn what each library has to offer, and then use them as per your requirement. Don’t go for one because everyone is using it. Pretty much all the libraries offer the same things. ‘mootools’ actually makes things faster because it’s so small, so many people should look at that if they don’t have too many hardcore OOP uses in their scripts. If you do, Prototype is probably the way to go since it has some pretty amazing classes and objects handling.

I went skipping on from Particletree to a nice extension of Prototype, which contains even more teensy weensy functions which we all want and use, albeit with longer drawn out codes. For example, functions to work with cookies and such. It extends an already jam–packed and very useful library! :)

SimpleJS seems like a good deal for very basic use, with small file sizes and independence from any other framework. But it doesn’t offer anything too big, which someone working with a library might be looking for. jQuery on the other hand seems very interesting, with small (compressed) file size and seemingly lot of uses. I’m definitely going to look more into that one. I want to move away from Prototype, but my ‘Search Suggest’ requires script.aculo.us, which uses Prototype. Together, they add about 60–70 Kbs to every page. There is not much difference in time due to caching, but it’s still a heavy deal.

Pick and choose

There seems to be no real perfect choice, or quite a balanced on either. I think libraries can truly be a great addition to your arsenal, but only if you know how to make full use of them. That can always take time, and you need to stick with one to get to know it properly. I’ve used Prototype ever since it came out, in some form or the other, and I still don’t know all it’s uses. So you can imagine how big it can be. I might as well stick to it, because a few of the things I use on my blog need it anyway, and it’s filled to the brim with all the functions one will ever need.

What do you think about the libraries out there? And which do you think is better than the rest?


Efendi said...

hm... the Particletree one is interesting :)

but Blogger have some too ;)

back then i had some thought to fully use all the available functions from the blogger js, and what it needs, and build some custom one from it too ;) just like you always did :)

it'll be alot more cleaner blog, if we can fully use all the blogger js :) no need for other framework :P

Aditya said...

Heh! Yes, but unforuntately for us, the libraries aren’t suited to work with Blogger’s JS :P

Also, they use a hacked out way to do object oriented programming in Javascript, since it wasn’t made for that purpose.

The newer version of Javascript however, will contain quite a few OOP elements, so that should reduce the need for these extra libraries :)

Deepak said...

Prototype has functionalities which I didn't even think about. I came to know only when I bumped on the full API document compiled by the great Sam Stephenson himself.