When writing an entire web application in javascript, it s very important to have well-organized code; maintaining a spaghetti-coded project will only cause you headaches and nightmares. In this tutorial, I ll show you how to modularize your code to make it easier to manage large javascript projects.

I was inspired to write this tutorial after watching a presentation entitled Scalable javascript Application Architecture by Nicolas C. Zakas (available on the YUI Theater). We ll take the theoretical code that he showed in his slides and extend and customize it to create a robust javascript system that will make it incredibly easy to build web apps on top of.We ll start by defining our modules; then, we ll build a sandbox for them to interact with. We ll also need a core to handle the modules, and a base (a JS framework) that gives the core an equalized environment to work on. We ll build our first core on jQuery, and then build an alternate core on Dojo.

We ll conclude this tutorial by discussing what the benefits and downsides of using such an architecture for javascript are.