Browserify is a tool that packages Node.js modules for a web browser.
Browserify is a tool that allows using Node.js modules on a client side.
Browserify combines selected modules into one file that can be added as a script
into an HTML page. It adds support for CommonJS-style require
and also emulates most of Node standard library. For example, http
module is emulated using XMLHttpRequest
and buffer
module uses TypedArrays.
Browserify Pros:
Ability to reuse the same code on a server (in Node.js applications) and on a client. Many Node modules that don't use IO or talk to file system just work with Browserify.
Support for CommonJS modules. Many developers prefer CommonJS to AMD due to more verbose notation of the latter:
CommonJS (Node):
// foo.js var bar = require('bar'); // use bar ... module.exports = // some object or function
AMD:
// foo.js define('foo', function (require) { var bar = require('bar'); // use bar ... return // some object or function });
Browserify doesn't prevent developer from using client-side libraried and frameworks like jQuery, YUI, Backbone, etc.
Browserify supports flexible transform options to handle non-javascript file require()s, like CoffeeScript, Handlebars/Jade templates, etc.
Browserify Cons:
Browserify adds a compilation step and thus requires a build process for your client-side code. Most AMD loaders allow writing modules that do not require a compilation at a price of verbocity.
Not all Node of standard library is supported. Notable omissions are support for Streams, File System, TCP and UDP networking, etc.
Native Addon Modules are not supported.
Browserify library for supporting Node API increases the size of resulting code. Some of that overhead can be reduced with code minifiers that supports dead code elimination like Google Closure Compiler or Uglify JS.