Package management

JS.Class comes with a package manager that makes it really easy to load libraries into your application on demand on all JS.Class’s supported platforms. You can tell it which file each module in your application lives in, and what other modules it depends on, and it takes care of resolving dependencies and loading your code for you. This means your application code only needs to specify which objects it needs, rather than which scripts to download in order to run.

For example, say I want to do something with the Console module. I just need to require it, and supply a function to run once all the requisite code has loaded:

JS.require('JS.Console', function() {
    JS.Console.puts('Hello, world!');
});

The package system only loads what is needed to get the objects you want, and it makes sure that each file is only downloaded once. Where possible, files are downloaded in parallel to improve performance, but it makes sure interdependent scripts run in the right order.

It is designed to be able to load any code from any domain, including from libraries that have their own package systems. While CommonJS is in some ways a better solution, it requires source code to follow certain conventions. JS.Packages lets you use a uniform interface to load any code you need, without requiring modifications to the source. This is particularly important on the web where you frequently use code you don’t have editing access to.