JavaScript Code compression Tool summary _javascript Tips

Source: Internet
Author: User
Tags closure documentation
UGLIFYJS

UGLIFYJS is a code compression tool built on the NODEJS server, which is currently compressed by jquery and has a better compression effect.

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

Online use: HTTP://MARIJNHAVERBEKE.NL/UGLIFYJS

How to use:

    1. Download Nodejs from http://nodejs.org and use Node.exe
    2. and download its latest version from UGLIFYJS's GitHub home page.
    3. Copy Node.exe to Uglifyjs bin directory
    4. Modify BIN\UGLIFYJS, require ("Uglify-js") to require (". /uglify-js "), if the hint can not find uglify-js words
    5. Run node uglifyjs–o fancyValidate.min.js fancyvalidate.js

Note The-o parameter is specified first, followed by the compressed file name followed by the-o parameter, and finally the source file.

If you don't have trouble downloading it, use it directly on the online version.

Microsoft Ajax minifier
Microsoft Ajax Minifier is a Microsoft-produced code compression tool that supports JavaScript and CSS code compression.

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

Download and install, the use of the method is also very simple:ajaxmin fancyvalidate.js –o fancyValidate.min.js

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

Google Closure Compiler

Google produced a code compression tool that requires the support of JRE (downloaded from http://www.java.com/zh_CN/download/)

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

First install JRE, simple use:java-jar compiler.jar --js hello.js --js_output_file Hello-compiled.js

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

YUI Compressor

The Yahoo!ui team's Code compression tool, which supports JavaScript and CSS code compression, also requires JRE support.

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

GitHub Home: Https://github.com/yui/yuicompressor

Download it from http://yuilibrary.com/download/yuicompressor/, simple to use:java-jar yuicompressor-2.4.7.jar myfile.js - o myfile-min.js

For more information, see the official homepage or Https://github.com/yui/yuicompressor/blob/master/doc/README

Packer

The famous JS Daniel Dean Edwards writes the compression tool, the compression ratio is also relatively high.

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

Time is relatively long, but still useful, but also provides a lot of parameter settings.

Jsmin

With the Packer era, only the annotation, blank and so on compression.

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

Provides a DOS command line version: Http://www.crockford.com/javascript/jsmin.zip

Simple to use:jsmin <fancyvalidate.js> fancyValidate.min.js

End

It's a simple introduction to this, and it's best to use JSLint (http://www.jslint.com/) to check your code before you compress it, or it may cause compression to fail.

Author: Embarrassing month

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.