This article mainly introduces five JavaScript code compression tools. Code compression (also called code Minimization) is a process to remove all unnecessary characters from the source code, for more information, see 5 recommended JavaScript code compression tools. Code compression (also called code Minimization) is a process of removing all unnecessary characters from the source code, including deleting all unnecessary space characters, new line characters, and comments. Code compression does not affect the source code function, but increases the loading time (and web application performance), because the size of the file to be downloaded is reduced.
The following are five excellent JavaScript code compression tools. I believe they can make your scripts lighter and better code performance.
I. YUI Compressor
Yahoo! YUI Compressor is a command line tool written in Java that helps you minimize JavaScript files. It is safe and has a higher compression ratio than other tools. In addition, YUI Compressor can also compress CSS files.
2. Google Closure Compiler
Google Closure Compiler is a tool that allows you to download and run JavaScript faster. This is a pretty good JavaScript compiler. Replacing the source language with machine language allows you to compile better JavaScript in JavaScript. You can use it to parse JavaScript, analyze and delete useless code, and rewrite and compress remaining code. It can also check syntax, variable reference, and type, and prompt common JavaScript errors.
Iii. JSMin
JSMin can delete comments and unnecessary spaces from JavaScript files. It can usually reduce the size by half to make the download faster. It also encourages more expressive programming styles.
Iv. Packer
Packer is also a popular JavaScript compression tool that can automatically create compressed version code. You only need to paste and then click the "Pack" button. It can achieve high compression and add advanced dynamic compression when running JavaScript.
5. Dojo ShrinkSafe
ShrinkSafe is also a common JavaScript code compression tool. Depending on your programming style, it can reduce the script size by 1/3 or more. Most importantly, ShrinkSafe will never change public variables or APIs. That is to say, you can put the compressed version of JavaScript into your page without changing its code.
Reward tools
Check which compression tool is more suitable for you, eliminating the trouble of installing various tools for testing.
Due to different applications, it may be difficult to find a suitable JavaScript code compression tool in many cases. Now we recommend a tool for you, you do not need to install all the compression tools to check which tool is suitable for you.
Try: The JavaScript CompressorRater
Note: This tool mainly targets JSMin, Dojo ShrinkSafe, YUI Compressor, and Packer