jsPax - Peace for the Scripts

Using jsPax

jsPax is a JavaScript Pakagesystem. The Core of jsPax is the File "package.js". To use jsPax Packages you need to load the Script into your HTML:

<SCRIPT SRC="package.js" TYPE="text/javascript"></script>

Then jsPax needs to know where your packages can be found:

$package.packageBase = 'http://www.example.com/packages/';

Now you can use packages:

$using('com.example.test',function() {com.example.test.doTest();});


a Sting or an Array of strings. These are(is) the name(s) of the package(s) your code depends on
a function that is called after all dependencies are loaded. This function can securely use these Packages.

$using() returns immediatelly and loads the Packages assynchonously. You can not expect the Packages to be loaded after $using() returns.

That is all you need to use existing packages.

Creating new packages

Basically a jsPax package is simply a JavaScript File, which at least creates an Object that has the same name as the packages name. package.js provides the function $package(name,object) to make that easier. The most simple package would then be:



a Sting containing the name of the Object that should be created
This Object is copied to the newly generated one.

Of course you can just create this Object at the end of an existing JS-File to make Packages from legacy code.

Installing packages

Packages are installed simply by copying them to the correct directory. The directory can be determined by $package.packageBase and the packages name:

Take the packages name and replace all '.' with '/'. Then append '.js' to that string and append the result to the package base. Then you have the URL where your package will be loaded from.

An Example: Your package is named 'com.example.test' and your package base is 'http://www.example.com/packages/'. Then you replaceall '.' with '/' in the Packagename: 'com/example/test', append '.js': 'com/example/test.js'. Now append this string to your package base: http://www.example.com/packages/com/example/test.js - that is the URL where jsPax will look for your package.

download package.js

I have used JSquash for compression.

You can use jsPax under the terms of the GNU LGPL


There is a testsuite for jspax as well. Please go ahead, test the server installation and report any problems to me.

Valid XHTML 1.0 Strict Valid CSS!