For a long time we’ve been struggling to manage the growing presence of JavaScript at 37signals. We needed a way to share common JavaScript components and behaviors across our applications and web sites. And we wanted the ability to organize our JavaScript source code into multiple files and folders without the overhead of including dozens of <script> tags on every page.

So we scratched the itch by creating Sprockets.

Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files. It takes any number of source files and preprocesses them line-by-line in order to build a single concatenation. Specially formatted lines act as directives to the Sprockets preprocessor, telling it to require the contents of another file or library first or to provide a set of asset files (such as images or stylesheets) to the document root. Sprockets attempts to fulfill required dependencies by searching a set of directories called the load path.

It helps you turn messy JavaScript into clean modules for development and a single .js file for deployment.