Browserify vs Require.js

In the world of web and server-side JavaScript development there is a need to be able to modularise your code and include it where it's needed without any fuss.

Up 'till now I've been using requirejs for modules but due to the pain it causes in development (and later deployment building) I have been searching for an alternative.

Hello Browserify

Browserify uses Node.js to compile your JavaScript source modules into a single file that you can include in your web pages.

It allows you to write code and modularise it very easily:

var MyModule = function () {  
    this._hello = true;

MyModule.prototype.hello = function (val) {  
    if (val !== undefined) {
        this._hello = val;
        return this;

    return this._hello;

module.exports = MyModule;  

This module just defines a class we can instantiate that has a simple getter/setter method called "hello()".

In browserify to use this module you just require it:

var MyModule = require('./myModule.js'),  

myModule = new MyModule();  

Simple and painless modules! I suggest you give browserify a good run, it will speed up your development and make your life a lot simpler!