Andrew Thorp changelog.com/posts

Jam - JavaScript package management for the browser

Caolan McMahon, the creator of Async, has released a new project called Jam. After using this project for a short while, I can say this project has huge potential. It is a package management tool that allows you to install, use and compile (minify) JavaScript libraries. Jam is a browser-focused project that uses RequireJS (AMD Modules) to load your website’s requirements.

Installation is simple:

npm install -g jamjs

Likewise, installing libraries is easy:

jam install jquery

Finally, you use the RequireJS to include the libraries:

<script src="jam/require.js"></script>
<script>
  require(['query'], function($){
    console.log("jQuery loaded!");
  });
</script>

One of the coolest features is the compilation, which will package all (optionally a specific set) of your libraries with RequireJS and allow you to load the optimized library as one optimized file.

jam compile jam/compiled.min.js

Then include compiled.min.js instead of require.js, the rest works like before:

<script src="jam/compiled.min.js"></script>
<script>
  require(['query'], function($){
    console.log("optimized jQuery loaded!");
  });
</script>

If you have a library you would like added as a package, feel free to fork the project and add it in. If, in the process, you run into conflicts or issues with NPM’s package.json, Caolan wants to hear about it!

Head on over to the project page or browse the source on GitHub.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00