For simple projects, I sometimes don't need the power offered by module loaders, bundlers or similar tools, and would prefer to just have a way of namespacing the project's modules, as opposed to a complete solution for requireing and using everything, vendor libraries included.

Browserify is really awesome, my only reason for not using it for every browser-based project is that I have yet to find a nice way of testing browserified projects using phantomjs. For projects that don't use the DOM, or projects which make sense both in node and the browser, browserify is perfect. The tests can be done from node, and each module to be tested can simply be required. Things aren't as simple when phantomjs is involved. Short of writing a very awkward require utility available in the tests, we need to test each module using the entire browserified bundle. This makes writing tests a bit more difficult, since the stack traces are less useful than if the modules were still separate files.

There are several namespacing patterns commonly used in browser-based projects that are simple enough to use without needing to bring in yet another library. For example:

// thing.js

(function(exports){...})(window.thing={});

// subthing.js

(function(exports){...})(window.thing.subthing={});

The problem with simply using those patterns is that you end up needing to add each new script to the list of scripts to be concatenated in your Gruntfile/makefile/whatever you use. Simply using a glob pattern like *.js is out of the question, since ordering matters (for eg, subthing.js uses things defined in thing.js, so it needs to appear after thing.js). This isn't a major problem, so most people just live with it. What I really wanted was to avoid implicit dependencies amongst scripts (one of the things AMD solves), but boilerplate-free and as simple to use as CommonJS. defuse is my attempt at this, by only loading a module when you use it for the first time, as opposed to when it is defined (lazy loading), but in a way that feels (to me) closer to CommonJS.

Assigns defuse's api methods to the global namespace. Excludes itself, unpollute and exports. If you would like these methods available globally out of the box, use the defuse-global.js or defuse-global.min.js builds.