There's been some hype around browserify lately, and it has been especially noticeable while I've been gulping around. So what is browserify and why would you use it?
First install browserify globally and the packages you want to use with npm.
npm install -g browserify npm install underscore
//app.js var _ = require('underscore'); var MyObj = require('./MyObj.js'); _.each(MyObj(), callback);
Lastly run the following command in your console.
browserify app.js > production.js
On face value that doesn't seem that revolutionary. But it actually is.
Using npm's require statement for development is awesome, it lets us easily bring in and manage necessary dependencies, handling all the file linking and concatenating. No more downloading dependencies from various websites, placing them into a local dev folder, and manually linking them into your html via script tags.
This is very useful to me for larger projects that have many dependencies, as the require statement allows you to easily separate and modularize each part of your program. When it comes time to concatenate your client files for production, browserify will not double up on required dependencies. Meaning if you require jquery in two different files within the same project, it will only add one copy of it to the final production version.
Browserify attracted my attention with its potential to quicken my workflow, as