JavaScript Libraries Playing Nice with Others?

Filed under

A common occurrence in Web 2.0 sites, and one that a recent Pingdom study notes, is the concurrent use of multiple JavaScript libraries. One explanation for this is that a required (more often desired) feature or widget may appear to only be available within one specific library.

This perception may have been true a few years ago but is certainly less likely today. What's more likely is that a developer sees a real or perceived obstacle in implementing or developing a widget with one library over another. "Either the widget exists but I can't seem to install it or it's missing and I'm having trouble building it."

Either way, I'm beginning to develop more of a purist's view -- choose one framework for a project or environment and stick with it.

If a widget doesn't exist in a framework, I won't simply use another framework just to add it. Why you ask? Simplicity and performance. It's great that all of these JavaScript libraries reside in their own name space so as not to interfere with the others, but this makes it too easy to add unnecessary complexity and overhead to a site. 

I've developed a few sites that embed the Gallery Photo Manager in Drupal. At its core Gallery uses YUI while Drupal uses jQuery. To complicate matters I implemented a Script.aculo.us-based Lightbox effect. The use of Script.aculo.us introduced repetition in basic DOM handling functions that are already provided in YUI and jQuery. Although the repetition only adds up to a few extra kilobytes, these kilobytes add up.

I've decided to replace the effect with a YUI equivalent. One less library to complicate things and fewer file transfers to slow things down. What do you think? Are you using multiple JS libraries? Are you contemplating a JavaScript consolidation effort?

Share