Libraries: On Size and Usage

As beginners, people who write Ajax applications (for the first time) tend to blindly slap on the Prototype JavaScript framework because of its fame and popularity. What then follows is the usual complaining on Prototype's size (over 60 kilobytes).

Size really doesn't matter at all when you're using most of the functionalities that your library provides no matter how big it is. However, it does matter when all you're using is a utility function from the whole library. What makes matters even worse is that most beginners don't even realize this and start reinventing their own wheel and never learn their lesson.

Common misutilization sins include:

  • Writing your own XMLHttpRequest wrapper
  • Only using the $() function
  • Directly manipulating element styles using
  • Not using library-provided iterators
  • Complaining how it breaks your crappy loops
  • Bluntly deleting blocks of code or modifying them because it "breaks" your old, rotting code

Other dumb practices include:

  • Including a whopping 200 kilobytes of just for a nice fading effect
  • Complain about how obnoxious DOM transversing and manipulating is when there are awesome DOM methods provided by the library sitting right in front of your face
  • Write lots of for loops when in fact you can use array extensions and save lots of time
  • Refusing to learn more about your library
  • Detesting JavaScript and refusing to learn the proper way to write it

If you want simple Ajax loading or effects, jQuery or mootools can easily do the job for you with a way smaller size. Learn your library and learn it well. You won't regret it.