Recommend 5 excellent JavaScript code compression tools. Code compression (also known as code minimization) is a process of eliminating all unnecessary characters from source code, including deleting all unnecessary space characters, new line characters, comments, etc. Code compression does not affect the functionality of the source code, but improves loading time (and the performance of web applications), because the size of the files to be downloaded is reduced.
Here are 5 excellent JavaScript code compression tools. I believe that they can make your scripts lighter and better code performance.
1. YUI Compressor
Produced by Yahoo! YUI Compressor is a command line tool written in Java to help you minimize JavaScript files. Very safe and has a higher compression ratio than other tools. Not only that, YUI Compressor can also compress CSS files.
2. Google Closure Compiler
Google Closure Compiler is a tool that allows JavaScript to be downloaded and run faster. This is a pretty good JavaScript compiler. Replace source language with machine language, allowing you to compile better JavaScript in JavaScript. You can use it to parse JavaScript, analyze, delete useless code, rewrite and compress remaining code, and more. It can also check syntax, variable references, and types, and prompt for common JavaScript errors.
3. JSMin
JSMin can remove comments and unnecessary spaces from JavaScript files, and it can usually reduce the size by half, making downloads faster. It also encourages a more expressive programming style.
4. Packer
Packer is also a popular JavaScript compression tool that can automatically create compressed versions of code. You just need to paste and click the "Pack" button. It can achieve high compression and add advanced dynamic compression when running with JavaScript.
5. Dojo ShrinkSafe
ShrinkSafe is also a commonly used JavaScript code compression tool. Depending on your programming style, it can reduce the size of the script by one third or more. Most importantly, ShrinkSafe never changes public variables or APIs, that is, you can put compressed versions of JavaScript into your page without changing the code that uses it.
Reward Tools
Detect which compression tool is more suitable for you, and avoid the trouble of installing various tools for testing.
Due to different applications, in many cases, it may be difficult to find a JavaScript code compression tool that suits you. Now I recommend a tool to detect which tool is suitable for you without installing all the compression tools.
Try it: The JavaScript CompressorRater
Note: This tool is mainly aimed at JSMin, Dojo ShrinkSafe, YUI Compressor and Packer