Tuesday, May 05, 2009

Some Core Javascript Functions

I recently worked on two different projects that involved a fair amount of Javascript centering around using the Google Maps API. In doing so I began to factor out some of the components to be reusable in a general Google Maps project. While I usually use the excellent Prototype Javascript library I didn't want to leak Prototype code into these reusable components. This led me to using these functions, borrowed / evolved from various places, as the core functions to support the components:

I think these functions are a pretty good representation of the baseline support you will want in many Javascript projects.


  1. Why not use Prototype? What's the fear or leakage?

  2. @sethladd - there are so many very good Javascript libraries that if someone were to want to use my code but wanted to use, say, JQuery, I would hate for them to have to load prototype just to support this code. With that said another way (possibly better) way to do this would be to have these functions be an adapter that called in to the coders Javascript library of choice.