Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Sprockets: A Ruby-powered JavaScript dependency library from 37signals

By Matthew Lang / February 20, 2009

Managing and organizing multiple JavaScript files in your Rails applications can be a real pain, especially when it comes to deploying your application and you need to minimize those JavaScript files down for better application performance.

Enter Sprockets, the new dependency management and concatenation library from 37signals (or, more specifically, Sam Stephenson). Once installed, Sprockets allows you to organize your application’s JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files.

Using directives at the start of each JavaScript file, Sprockets can determines which files your current JavaScript file depends on. When it comes to deploying your application, Sprockets then uses these directives to turn your multiple JavaScript files into a single file for better performance.

Sprockets also allows you bundle assets with your JavaScript, as well as allowing you to insert string constants in your JavaScript files, using a YAML file.

Sprockets is available as a Ruby gem or as a Rails plugin. The Sprockets source code is also available on GitHub.

Post by Matthew Lang - Matthew Lang is an ERP developer with a keen interest in Ruby and Rails programming.

Comments

  1. Paul says:

    It would have been useful some insight about the experience of using the library instead of rewriting the 37s blog entry

  2. justin says:

    this is super great, way to go sam yet again

  3. Henry Krinkle says:

    @Paul: Sprockets just came out. How much experience do you expect the Matthew Lang to have acquired at this stage?

  4. lian says:

    sprockets looks interesting, sounds alot like a project started last year, execpt the rails part but ruby love aswell: github.com/lian/javascript-bundle ..allways liked the idea of a bundle with most common javascript libraries keept updated and documented. only needs some contributers! ;)

Other Posts to Enjoy

Twitter Mentions