Summary of JavaScript code compression tools

Source: Internet
Author: User

UglifyJS

UglifyJS is a code compression tool built on the nodeJS server. Currently, jQuery uses this tool to compress and the compression effect is better.

GitHub home: http://github.com/mishoo/UglifyJS/

Online use: http://marijnhaverbeke.nl/uglifyjs

Usage:

  1. Download nodejs from the http://nodejs.org and use node.exe
  2. Download the latest version from the GitHub homepage of UglifyJS.
  3. Copy node.exe to the bin directory of UglifyJS.
  4. Modify bin \ uglifyjs and change require ("uglify-js") to require ("../uglify-js"). If you are prompted that uglify-js cannot be found
  5. RunNode uglifyjs-oFancyValidate. min. js fancyValidate. js

Note that you must first specify the-o parameter, followed by the compressed file name, and finally the source file.

If the download is troublesome, use its online version directly.

Microsoft Ajax Minifier
Microsoft Ajax Minifier is a Microsoft code compression tool that supports JavaScript and css code compression.

Official homepage: http://ajaxmin.codeplex.com/

Download and install fancyValidate. js-o fancyValidate. min. js.

For more parameter usage, see the official documentation: http://ajaxmin.codeplex.com/wikipage? Title = Command-Line % 20 Switches

Google Closure Compiler

The Code compression tool produced by Google requires support from JRE (download from http://www.java.com/zh_cn/download /)

Official homepage: http://code.google.com/p/closure-compiler/

Install JRE first, which is easy to use:Java-jar compiler. jar -- JsHello. js-- Js_output_fileHello-compiled.js

For more parameter descriptions, see the relevant documentation: https://developers.google.com/closure/compiler/docs/overview

YUI Compressor

Yahoo! The Code compression tool developed by the UI team supports JavaScript and css code compression, and JRE is also required.

Official homepage: http://developer.yahoo.com/yui/compressor/

GitHub home: https://github.com/yui/yuicompressor

Download the following code from http://yuilibrary.com/download/yuicompressor:Java-jar yuicompressor-2.4.7.jarMyfile. js-OMyfile-min.js

For more parameter descriptions, see the official homepage or https://github.com/yui/yuicompressor/blob/master/doc/README

Packer

The famous js Daniel Dean Edwards writes a high compression ratio.

Official homepage: http://dean.edwards.name/packer/

It takes a long time, but it is still easy to use and many parameter settings are provided.

JSMIN

In the age similar to Packer, only comments and blank spaces are compressed.

Official homepage: http://www.crockford.com/javascript/jsmin

Provides a doscommand line version: http://www.crockford.com/javascript/jsmin.zip

Easy to use:Jsmin <FancyValidate. js>FancyValidate. min. js

End

Here, it is easy to use JSLint (http://www.jslint.com/) to check the code before compression, otherwise it is likely to cause compression failure.

Author: jinyue

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.