But YUI compressor also has a shortcoming, that is, the operation is not user-friendly. You have to enter the command line to operate, which is also a bit inconvenient in practical applications. Today I discovered a software developed by Taobao people - TBCompressor. This software is improved on the basis of YUI compressor. It is very simple to use. For details, please see lifesinger's "TBCompressor – JS and CSS Compression Tool" article. The following is how to use TBCompressor. To download, please go to http://code.google.com/p/ourtools/downloads/list and select yuicompressor_2.4.2 .zip file.
- After unzipping, click install.cmd inside to install. If you want to uninstall, click uninstall.cmd.
- Right-click on the JS file or CSS file to be compressed, and select Process with YUICompressor in the pop-up menu;
- A compressed file will be generated in the same directory as the original file. The file name is the original file name followed by "-min". For example, if the original file name is "test.js", then the compressed file will be "test-min.js". It is recommended that the file name be of type name.source.js, which will automatically compress and generate the name.js file.
Note: TBCompressorThe default encoding type of compressed files is GB18030. If you want to compress files of other encoding types, modify the compressor.cmd file, just replace GB18030 inside with the encoding type you want. For example, if I use UTF8, just change GB18030 to utf-8. The compression rate of TBCompressor is not too high, but it is very safe and can well preserve Hacks in CSS files. If you are a person who is obsessed with code, you can also use compressed files to optimize.
Here are some websites that optimize JS and CSS online. However, these compressed codes may cause errors when running, so be careful when using them:
- http://javascriptcompressor.com/
- http://www.xmlforasp.net/JSCompressor.aspx
- http://compressorrater.thruhere.net/
- http://jsbeautifier.org/
- http://www.codebeautifier.com/
- http://www.lonniebest.com/FormatCSS/
- http://www.cssdrive.com/index.php/main/csscompressor/
- http://tools.arantius.com/css-compressor