See
How to develop, publish and use a javascript library ?