Sortie is a set of javascript libraries that provide a common interface between browsers and javascript libraries, and also allows for library versioning and dynamic library loading. Sortie has ajax libraries built in (called pipes), but is designed to let you mix and match ajax libraries (Dojo, YUI, etc).

The point of this library, by the way, is to sit above all your other javascript libraries and manage them – versions, includes, requires, etc. It can be used by itself for ajax stuff as well, but odds are you’re already using something for that purpose. There are other bits that are helpful too, like Map, List, and Set objects (in collections).

It uses a pseudo-preprocessor to include and require libraries. For example:

Sortie.Core.$({
    require:new Array(
        { c:"Sortie.Util.Collections", v:"0.2"},
        { c:"Some.Other.Class" }
    )
});

that makes Sortie look for the classes Some.Other.Class, and Sortie.Util.Collections from within your javascript code – the latter must be version 0.2 or higher (set in the namespace metadata). From your single main javascript include you could do something like this:

Sortie.Core.$({
    include:new Array(
        "Code/Util/Cookie.js",
        "Code/Util/Search.js"
    )
});

To include those javascript libraries on page load (meaning, you manage javascript includes from within the javascript files, not on the html page).

Along with Sorite, my JU Test (Javascript Unit Test) bit is going open source as well and is included in the Sorite distribution. JU Test allows you to write unit tests, and when you run them you also get an interactive environment to help debug stuff. Since it runs in the browser, it helps when trying to find browser specific bugs. You can see and example of JU Test here (After the test runs, hit enter in the top area to activate the interactive console – type help for a small bit of help)

The libraries are well documented, and the documentation can be generated from the source using NaturalDocs.

I am releasing the code under the LGPL. There is one slight flaw with the libraries as they stand. People were making fun of the way I was creating javascript objects which was something like this:

function HTTPConnectFactory(){;}

function __hcf__getInstance() {
    ...
}

HTTPConnectFactory.prototype.getInstance = __hcf__getInstance();

I succumbed to the pressure (which was dumb of me I know), and made all the objects in Sorite like this (per many people suggestions):

function HTTPConnectFactory(){
    this.getInstance = function() {
        ...
    }
}

While this might look cleaner, it’s completely wasteful as each new instance of the HTTPConnectFactory object creates its own copy of the getInstance function for no good reason. So, at some point those need to get changed back to the faster, less memory intensive way (this should only show it’s head if you create a lot of instances however).

And lastly, Sortie comes with a build script that will compress and combine all of the Sortie libraries into a single file that, at the time of this writing, is 24KB (and can be made smaller by not “compiling in” portions of the code).

Sorite is used as part of 9ne which I just open sourced. To be consistent, I am open sourcing Sorite (that and the iphone news – people might find this helpful. It was designed to work with Safari in mind (as well as FF and IE)).

If you’d like to download a copy of Sortie, you need to download and install git (the same as with 9ne and described in the 9ne release post). To get the Sorite code just do:

$ cd Projects
$ git clone http://sortie.robrohan.com/repo/Sortie.git Sorite

Enjoy.