The JavaScript Library Trap

Posted on Thursday, February 7th, 2008

Recently I used a couple of JavaScript frameworks for the first time. Previously I have been trying to understand the JavaScript that underpins all the available libraries along with the fights to get different browsers to behave the same way. I never planned to use a library until I fully understood what was going on, but a project at work was kicked off with jQuery and I was left to discover how easy it all was by myself. Then, a couple of weeks later, a JavaScript course paid heavy attention to Prototype. The ease of slipping into using either of these libraries got me thinking.

Falling In Love… With A Library

I’ve been using it for no more than two weeks and jQuery feels like a hammer, all my JavaScript problems look like nails. My problem is that I know I shouldn’t be falling for just the one library, but I don’t know where else to look! I read through Jonathan Snook’s slides from Web Directions North 08 on workin with AJAX frameworks and I am waiting for the podcast for greater detail.

What I really want to know is, what is the best way not to fall into the JavaScript library trap? If you use libraries, which ones do you use and how do you decide? How do you decide when not to use one too, as that is all important? And finally, do you have your own library of your own utility functions?

I hope you can help me out with your experience.

If you enjoyed this post, why not subscribe to Unintentionally Blank

Comments

  1. Montoya Says:

    I am a huge supporter of jQuery and I have 3 situations in which I will use it:

    • When cross-browser compatibility is going to be difficult (DOM manipulation, AJAX, etc.)
    • When I need to do a number of things, like AJAX requests, dynamic styling, and animation all in one project
    • When it has to be done yesterday

    Reason 1 is almost always true. It’s nice to know that the library I use wraps up all the cross-browser workarounds so I don’t have to get my hands dirty!


  2. Phil Says:

    Thanks Montoya, have you used any other libraries? Is there a reason that you are so behind jQuery over any others? Don’t they all tend to deal with those three situations well?


  3. Jonathan Nicol Says:

    The extent of my js library experience is Scriptaculous, which is built on top of Prototype. I’ve used it for its add drag ‘n’ drop functionality, and it’s also included in Rails so it gets used in lots of Rails web apps such as 37signals products (not surprising - Prototype, Rails and 37Signals apps are all made by the same guy!).

    I also had a small play with jQuery and was impressed.

    Another library to throw into the mix is mootools, though I have no personal experience using it.

    Previously I “rolled my own” javascripts for Dom manipulation and AJAX functionality, but I see myself using libraries much more in the future. I am always hesitant to get locked in to someone else’s way of doing things, but I also see no need to reinvent the wheel!


  4. Phil Says:

    Hi Jonathan,

    Scriptaculous does seem good for effects, and one of my colleagues has suggested to me before that Mootools is good all round.

    I find it interesting that Prototype and Scriptaculous come with Rails, though I have seen that there is an effort to create a version that uses jQuery instead!

    It is hard to know what to use and I really would like to know what the particular strengths of each library are. I guess the only way to really find out is to use them, my only problem is that all I want to use right now is jQuery!


Leave a Comment