Awesome Open Source
Awesome Open Source


a browserify plugin that runs various optimizations, so you don't have to install them all manually.

npm travis standard

npm install --save-dev tinyify

browserify -p tinyify app.js


  • unassertify - Remove assert() calls
  • envify - Replace environment variables—by default, replaces NODE_ENV with "production"
  • uglifyify - Remove dead code from modules
  • common-shakeify - Remove unused exports from modules
  • browser-pack-flat - Output a "flat" bundle, with all modules in a single scope
  • bundle-collapser - When using the --no-flat option, bundle-collapser replaces file paths in require() calls with short module IDs
  • minify-stream - Uglify the final bundle

browser-pack-flat and bundle-collapser are both not used if the --full-paths option is passed to Browserify. This way you can still get all of tinyify's other optimizations when building for disc.


Options can be provided on the command line using subarg syntax, or in a separate options object using the browserify API.

env: {}

Supply custom environment variables for envify.

b.plugin('tinyify', {
  env: {

This option is only available in the API. On the CLI, you can define environment variables beforehand instead:

PUBLIC_PATH= browserify app.js -p tinyify

--no-flat, flat: false

Disable browser-pack-flat. This enables bundle-collapser instead which will still shrink the output bundle a bit by replacing file paths with short module IDs.

browserify app.js -p [ tinyify --no-flat ]
b.plugin('tinyify', { flat: false })

More options?

If you need further customisation, I recommend installing the tools separately instead:

npm install --save-dev unassertify envify uglifyify common-shakeify browser-pack-flat uglify-js
browserify entry.js \
  -g unassertify \
  -g envify \
  -g uglifyify \
  -p common-shakeify \
  -p browser-pack-flat/plugin \
| uglifyjs -cm \
> output.js

Or with the Node API:

    .transform('unassertify', { global: true })
    .transform('envify', { global: true })
    .transform('uglifyify', { global: true })
    .pipe(require('minify-stream')({ sourceMap: false }))

Alternatively you can fork this repo and publish it on npm under a scope with your modifications.



Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
javascript (70,402
browserify (49
minify (39
optimize (19
tree-shaking (18