Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minify multiple files with UglifyJS

Is it possible to compress multiple files with UglifyJS?

Something like...

uglifyjs -o app.build.js appfile1.js appfile2.js ... 

Also, I am running Uglify via NodeJS in Windows Command Prompt

like image 854
jcreamer898 Avatar asked Jan 11 '12 00:01

jcreamer898


People also ask

What is the difference between minify and uglify?

Minification is just removing unnecesary whitespace and redundant / optional tokens like curlys and semicolons, and can be reversed by using a linter. Uglification is the act of transforming the code into an "unreadable" form, that is, renaming variables/functions to hide the original intent...

Does Uglify minify?

To 'uglify' a JavaScript file is to minify it using Uglify. Uglification improves performance while reducing readability.

What is the purpose of the Uglifyjs?

What is UglifyJS? # UglifyJS is best known as a JavaScript minifier. Minification is a valuable performance enhancing technique as it removes whitespace and unnecessary characters within a file to make it smaller and thus, load faster.


1 Answers

Actually what you want to do (trick it into thinking its just 1 file) is just cat it

Linux

cat file1.js file2.js file3.js file4.js | uglifyjs -o files.min.js 

Windows (untested)

type file1.js file2.js > uglifyjs -o files.min.js 

OR

type file1.js file2.js > merged.files.js uglifyjs -o merged.files.js 
like image 178
Jakub Avatar answered Oct 06 '22 07:10

Jakub