JavaScript code compression tool summary _ javascript skills

Source: Internet
Author: User
To make the page Load faster, you often need to compress the javascriptcss code to reduce the size. Here we will briefly list the used compression tools and use them as an archive. 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 href = "http://marijnhaverbeke.nl/uglifyjs" target = _ blank> http://marijnhaverbeke.nl/uglifyjs

Usage:

  1. Download nodejs from http://nodejs.org href = "http://nodejs.org/" target = _ blank> http://nodejs.org with 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/href = "http://ajaxmin.codeplex.com/" target = _ blank> 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 href = "http://ajaxmin.codeplex.com/wikipage? Title = Command-Line % 20 Switches "target = _ blank> http://ajaxmin.codeplex.com/wikipage? Title = Command-Line % 20 Switches

Google Closure Compiler

Google's code compression tool requires support for JRE (from http://www.java.com/zh_CN/download/ href = "http://www.java.com/zh_CN/download/" target = _ blank> http://www.java.com/zh_cn/download/download)

Official homepage: http://code.google.com/p/closure-compiler/ href = "http://code.google.com/p/closure-compiler/" target = _ blank> 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 href = "https://developers.google.com/closure/compiler/docs/overview" target = _ blank> 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/ href = "http://developer.yahoo.com/yui/compressor/" target = _ blank> http://developer.yahoo.com/yui/compressor/

GitHub home: https://github.com/yui/yuicompressor href = "https://github.com/yui/yuicompressor" target = _ blank> https://github.com/yui/yuicompressor

From http://yuilibrary.com/download/yuicompressor/ href = "http://yuilibrary.com/download/yuicompressor/"> http://yuilibrary.com/download/yuicompressor/download volumes, simple to use:Java-jar yuicompressor-2.4.7.jarMyfile. js-OMyfile-min.js

For more parameter descriptions, see official homepage or https://github.com/yui/yuicompressor/blob/master/doc/README href = "https://github.com/yui/yuicompressor/blob/master/doc/README" target = _ parent> 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/ href = "http://dean.edwards.name/packer/" target = _ blank> 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 href = "http://www.crockford.com/javascript/jsmin" target = _ blank> http://www.crockford.com/javascript/jsmin

Provides a doscommand line version: http://www.crockford.com/javascript/jsmin.zip href = "http://www.crockford.com/javascript/jsmin.zip" target = _ blank> http://www.crockford.com/javascript/jsmin.zip

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

End

Here, it's better to use JSLint (http://www.jslint.com/href = "http://www.jslint.com/" target = _ blank> http://www.jslint.com/) to check the code before compression, otherwise, compression may fail.

Author: jinyue

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.