Monday, October 12, 2009

RunJS updated: simple modules and i18n bundles

I pushed some changes to RunJS, the stand-alone JavaScript file/module loader.

Newest changes are support for simple module definitions and internationalization (i18n) bundles.

Simple module definitions are possible when there are no dependencies for the module. In that case the function wrapper for the module is not needed:

color: "red",
size: "large"
i18n bundle support is handy for separating out strings that might need to be translated into other languages. Quick example for a my/nls/colors.js that will define a bundle:

"root": {
"red": "red",
"blue": "blue",
"green": "green"
"fr-fr": ""
Then define a file at my/nls/fr-fr/colors.js that has the following contents:

"red": "rouge",
"blue": "bleu",
"green": "vert"
See the documentation for more information.

If you want to try out the latest code, you can use one of the following URLs to fetch the code:
In addition to the documentation, some of the test files might be of interest to see how RunJS can be used.

RunJS is still nice and small with these new features, around 2.7KB, when minified via YUICompressor and gzipped.

No comments: