User Tools

Site Tools


java-script:minification-uglification

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java-script:minification-uglification [2023/08/09 19:48] – [Uglification] odeftajava-script:minification-uglification [2023/08/09 19:53] (current) odefta
Line 11: Line 11:
 Install it: Install it:
 <code> <code>
-npm install terser+npm install terser -g
 </code> </code>
  
 Minify a file: Minify a file:
 <code> <code>
-npx terser file.js -o file.min.js+terser file.js -o file.min.js
 </code> </code>
  
Line 27: Line 27:
 Install it: Install it:
 <code> <code>
-npm install uglify-js+npm install uglify-js -g
 </code> </code>
  
 Uglify a file using both **compression (-c)** and name **mangling (-m)**: Uglify a file using both **compression (-c)** and name **mangling (-m)**:
 <code> <code>
-npx uglifyjs file.js -o file.min.js -c -m+uglifyjs file.js -o file.min.js -c -m
 </code> </code>
  
Line 49: Line 49:
 </code> </code>
  
 +<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>
  
- +<note tip> 
- +Most modern web development workflows incorporate these processes into a build system like **[[https://webpack.js.org/|Webpack]] or [[https://gulpjs.com/|Gulp]]**. \\ This can automate the minification and uglification process as part of your regular development and deployment process, and may include other optimizations like tree-shaking to remove unused code. 
 +</note>
  
  
java-script/minification-uglification.1691599701.txt.gz · Last modified: 2023/08/09 19:48 by odefta