A browserify transform which minifies your code using UglifyJS2
Installations
npm install uglifyify
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
9.8.0
NPM Version
6.8.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
hughsk
Download Statistics
Total Downloads
13,205,569
Last Day
2,089
Last Week
15,373
Last Month
103,665
Last Year
1,440,503
GitHub Statistics
377 Stars
96 Commits
61 Forks
9 Watching
2 Branches
22 Contributors
Bundle Size
371.05 kB
Minified
107.55 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.0.2
Package Id
uglifyify@5.0.2
Size
5.37 kB
NPM Version
6.8.0
Node Version
9.8.0
Publised On
20 Aug 2019
Total Downloads
Cumulative downloads
Total Downloads
13,205,569
Last day
-14.4%
2,089
Compared to previous day
Last week
-31.3%
15,373
Compared to previous week
Last month
-39.2%
103,665
Compared to previous month
Last year
5.8%
1,440,503
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
5
Dev Dependencies
6
uglifyify
A Browserify v2 transform which minifies your code using terser (a maintained fork of uglify-es).
Installation
1npm install uglifyify
Motivation/Usage
Ordinarily you'd be fine doing this:
1browserify index.js | uglifyjs -c > bundle.js
But uglifyify is able to yield smaller output by processing files individually instead of just the entire bundle. When using uglifyify you should generally also use Uglify, to achieve the smallest output. Uglifyify provides an additional optimization when used with Uglify, but does not provide all of the optimization that using Uglify on its own does, so it's not a replacement.
Uglifyify gives you the benefit of applying Uglify's "squeeze" transform on each file before it's included in the bundle, meaning you can remove dead code paths for conditional requires. Here's a contrived example:
1if (true) { 2 module.exports = require('./browser') 3} else { 4 module.exports = require('./node') 5}
module.exports = require('./node')
will be excluded by Uglify, meaning that
only ./browser
will be bundled and required.
If you combine uglifyify with envify, you can make this a little more accessible. Take this code:
1if (process.env.NODE_ENV === 'development') { 2 module.exports = require('./development') 3} else { 4 module.exports = require('./production') 5}
And use this to compile:
1NODE_ENV=development browserify -t envify -t uglifyify index.js -o dev.js && 2NODE_ENV=production browserify -t envify -t uglifyify index.js -o prod.js
It should go without saying that you should be hesitant using environment
variables in a Browserify module - this is best suited to your own
applications or modules built with Browserify's --standalone
tag.
File Extensions
Sometimes, you don't want uglifyify to minify all of your files – for example,
if you're using a transform to require
CSS or HTML, you might get an error
as uglify expects JavaScript and will throw if it can't parse what it's given.
This is done using the -x
or --exts
transform options, e.g. from the
command-line:
1browserify \ 2 -t coffeeify \ 3 -t [ uglifyify -x .js -x .coffee ]
The above example will only minify .js
and .coffee
files, ignoring the rest.
Global Transforms
You might also want to take advantage of uglifyify's pre-bundle minification to produce slightly leaner files across your entire browserify bundle. By default, transforms only alter your application code, but you can use global transforms to minify module code too. From your terminal:
1browserify -g uglifyify ./index.js > bundle.js
Or programatically:
1var browserify = require('browserify') 2var fs = require('fs') 3 4var bundler = browserify(__dirname + '/index.js') 5 6bundler.transform('uglifyify', { global: true }) 7 8bundler.bundle() 9 .pipe(fs.createWriteStream(__dirname + '/bundle.js'))
Note that this is fine for uglifyify as it shouldn't modify the behavior of your code unexpectedly, but transforms such as envify should almost always stay local – otherwise you'll run into unexpected side-effects within modules that weren't expecting to be modified as such.
Ignoring Files
Sometimes uglifyjs will break specific files under specific settings – it's
rare, but does happen – and to work around that, you can use the ignore
option. Given one or more glob patterns, you can filter out specific files
this way:
1browserify -g [ uglifyify --ignore '**/node_modules/weakmap/*' ] ./index.js
1var bundler = browserify('index.js') 2 3bundler.transform('uglifyify', { 4 global: true, 5 ignore: [ 6 '**/node_modules/weakmap/*' 7 , '**/node_modules/async/*' 8 ] 9}) 10 11bundler.bundle().pipe(process.stdout)
Source Maps
Uglifyify supports source maps, so you can minify your code and still see the original source – this works especially well with a tool such as exorcist when creating production builds.
Source maps are enabled when:
- You're using another transform, such as coffeeify, that inlines source maps.
- You've passed the
--debug
flag (ordebug
option) to your browserify bundle.
Enabling --debug
with browserify is easy:
1browserify -t uglifyify --debug index.js
1var bundler = browserify({ debug: true }) 2 3bundler 4 .add('index.js') 5 .transform('uglifyify') 6 .bundle() 7 .pipe(process.stdout)
If you'd prefer them not to be included regardless, you can opt out
using the sourcemap
option:
1browserify -t [ uglifyify --no-sourcemap ] app.js
1var bundler = browserify('index.js') 2 3bundler.transform('uglifyify', { sourceMap: false }) 4 .bundle() 5 .pipe(process.stdout)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Warn: project license file does not contain an FSF or OSI license.
Reason
Found 12/26 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 16 are checked with a SAST tool
Score
3.5
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to uglifyify
@frida/uglifyify
A browserify transform which minifies your code using terser
@browserify/uglifyify
A browserify transform which minifies your code using Terser
@vendhq/uglifyify
A browserify transform which minifies your code using terser
uglifyify2
A browserify transform which minifies your code using UglifyJS2