This project demonstrates how to use Terser for JavaScript minification. It provides examples of both simple code minification and file-based minification, showcasing how to minify JavaScript code using Terser.
-
Clone the repository:
git clone https://github.com/BaseMax/terser-demo.git
-
Install the dependencies:
cd terser-demo npm install
Minifying Inline Code
In the code.js
file, you can find an example of how to minify a block of JavaScript code using Terser. Run the script to see the minified version of the provided code.
Minifying Files
In the file.js
file, there’s an example of how to read a JavaScript file (example-code.txt.js
), minify it, and save the result to another file (example-code.js). This demonstrates how to use Terser for file-based minification.
Minifying Code with Source Maps
The test.js
file shows how to minify JavaScript code while generating a source map. This can be useful for debugging and maintaining the connection between the minified code and the original source code.
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright 2025, Max Base