java-script:minification-uglification
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
java-script:minification-uglification [2023/08/09 19:48] – [Uglification] odefta | java-script:minification-uglification [2023/08/09 19:53] (current) – odefta | ||
---|---|---|---|
Line 11: | Line 11: | ||
Install it: | Install it: | ||
< | < | ||
- | npm install terser | + | npm install terser |
</ | </ | ||
Minify a file: | Minify a file: | ||
< | < | ||
- | npx terser file.js -o file.min.js | + | terser file.js -o file.min.js |
</ | </ | ||
Line 27: | Line 27: | ||
Install it: | Install it: | ||
< | < | ||
- | npm install uglify-js | + | npm install uglify-js |
</ | </ | ||
Uglify a file using both **compression (-c)** and name **mangling (-m)**: | Uglify a file using both **compression (-c)** and name **mangling (-m)**: | ||
< | < | ||
- | npx uglifyjs file.js -o file.min.js -c -m | + | uglifyjs file.js -o file.min.js -c -m |
</ | </ | ||
Line 49: | Line 49: | ||
</ | </ | ||
+ | <note top> | ||
+ | Terser is a more recent tool and is often recommended for modern JavaScript, as it supports newer syntax features that UglifyJS might not handle. | ||
+ | </ | ||
- | + | <note tip> | |
- | + | Most modern web development workflows incorporate these processes into a build system like **[[https:// | |
+ | </ | ||
java-script/minification-uglification.1691599701.txt.gz · Last modified: 2023/08/09 19:48 by odefta