Question: Is it possible to use `require()` (or something similar) on client side?

**Example**

```
var myClass = require('./js/myclass.js');

```

Answer: 
I have found that in general it is recommended to preprocess scripts at compile time and bundle them in one (or very few) packages with the `require` being rewritten to some "lightweight shim" also at compile time.

I've Googled out following "new" tools that should be able to do it

* <http://mixu.net/gluejs/>
* <https://github.com/jrburke/almond>
* <https://github.com/component/builder2.js>

And the already mentioned `browserify` should also fit quite well - <http://esa-matti.suuronen.org/blog/2013/04/15/asynchronous-module-loading-with-browserify/>

### What are the module systems all about?

* Older Stack Overflow explanation - [Relation between CommonJS, AMD and RequireJS?](https://stackoverflow.com/questions/16521471/relation-between-commonjs-amd-and-requirejs)
* Detailed discussion of various module frameworks and the `require()` they need is in [Addy Osmani - Writing Modular JavaScript With AMD, CommonJS & ES Harmony](http://addyosmani.com/writing-modular-js/)
Here's a light weight way to use require and exports in your web client. It's a simple wrapper that creates a "namespace" global variable, and you wrap your CommonJS compatible code in a "define" function like this:

```
namespace.lookup('org.mydomain.mymodule').define(function (exports, require) {
    var extern = require('org.other.module');
    exports.foo = function foo() { ... };
});

```

More docs here:

<https://github.com/mckoss/namespace>