Google's JavaScript compression tools are several of the best JavaScript compression obfuscation tools

Source: Internet
Author: User

Today's web projects are always inseparable from a large number of JavaScript files, and the size of JS files is getting bigger and bigger, which also increasingly affects the page's perceived performance (perceived performance ). Therefore, we will compress the JS file. On the one hand, we use gzip, while on the other hand, we will remove comments and spaces in the JS file and compress the local variable length. For some mature class libraries, they all provide "complete comments" and "strongly COMPRESSED" versions. However, sometimes we need to fix bugs in the class library by ourselves, which can only be modified in the comment version, and we can't do anything about the compressed version. In addition, custom script files are also worth a lot of pressure. Therefore, I usually have a script compression tool in my project.

There are many compression script tools, such as the old jsmin or Yui compressor (YC), which can be used to compress script files (the latter can also process CSS ). However, in the new project, I used the new tool: Google closure Compiler (GC ). GC can be used in many ways, such as web edition, web API edition, and independent application edition. The difference between GC and YC is that YC is a compressor, while GC is a compiler. That is to say, GC Compression not only removes comments and spaces, it can be further rewritten to save space while ensuring code correctness. one byte is counted as one byte, for example:

1 a = new Object    => a = {}
2 a = new Array     => a = []
3 if (a) b()        => a && b()
4 return 2 * 3;     => return 6;

Google closure compiler provides three compression methods: Space removal, simple compression, and advanced compression. Simple compression basically only removes comments and spaces (similar to Yui compressor). In addition to the above functions, advanced compression also supports rename variable name and even some statement! Very good and powerful!

Google JavaScript closure compiler has local and online versions:

Click here to download JavaScript closure Compiler

Online JavaScript closure Compiler

Appendix:

Closure compiler is a javascript optimizing compiler. it parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. it also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. it is used in memory of Google's JavaScript apps, including Gmail, Google Web search, Google Maps, and Google Docs.

 

 

 

Several cutting-edge JavaScript compression obfuscation tools
Memtronic's freeware html/JavaScript cruncher-compressor v1.0k
The compression is not very good. The obfuscated code is completely unreadable and the compression ratio can reach 50%. It can be used in IE 5 +/ns 7.0/Mozilla/opera 7.0.

Second, I recommend Rob Seiler's packer
This compression obfuscation tool works well. It has three versions:. net, Perl, wsh, and wsh. It is suitable for wsh scripts on Windows platforms and has detailed instructions on command line operations.

Third, ESC produced by saltstorm
This tool can customize the compression level and whether to confuse it. Of course, it does not have any disadvantages. The compression effect is average, and each JS statement must end with a semicolon, and it does not work with braces.

 

Personal debut
Memtronic's freeware html/JavaScript cruncher-compressor v1.0k
The compression is not very good. The obfuscated code is completely unreadable and the compression ratio can reach 50%. It can be used in IE 5 +/ns 7.0/Mozilla/opera 7.0.

Second, I recommend Rob Seiler's packer
This compression obfuscation tool works well. It has three versions:. net, Perl, wsh, and wsh. It is suitable for wsh scripts on Windows platforms and has detailed instructions on command line operations.

Third, ESC produced by saltstorm
This tool can customize the compression level and whether to confuse it. Of course, it does not have any disadvantages. The compression effect is average, and each JS statement must end with a semicolon, and it does not work with braces.

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.