We use JavaScript libraries nearly every day. When you’re just getting started, having something like jQuery is fantastic, mainly because of the DOM. First, the DOM can be rather rough to wrangle for a beginner; it’s a pretty poor excuse for an API. Secondly, it’s not even consistent across all browsers.
http://code.tutsplus.com/tutorials/build-your-first-javascript-library–net-26796 sample
http://benalman.com/news/2010/11/immediately-invoked-function-expression/
origin - http://www.pipiscrew.com/?p=2173 build-your-first-javascript-library