Use Microsoft Ajax minifier technology to efficiently compress JS files

Source: Internet
Author: User

Nowadays, more and more WordPress Themes use jquery and other JS plug-ins. These JS files are usually located before

Microsoft once produced a Microsoft Ajax
Minifier's Js compression tool is suitable for all JS files. I am a perfectionist and want to keep improving everything, so the following comments should be able to understand and understand. We only need to use it, so we don't have to go into the technical aspects.

Advantages: high compression rate, secure and reliable, and code specifications

Disadvantage: You need to manually enter a command to execute the operation.

Step 1: download the latest Microsoft
Ajax minifier 1.1, click the I agree button, download the file and save it to the desktop, double-click it to install it, and find Microsoft Ajax minifier command prompt in the Start-Program-Microsoft Ajax minifier folder, click to display the familiar cmd command window,

Step 2: copy the Javascript file you want to compress to the root directory, such as D or E, other than drive C. Why? Some friends who use win 7 have restrictions on the operation permissions of drive C, which will prevent files from being generated. We can just put them in the drive D and directory. The following describes three compression methods: (for example, a demo. js file needs to be compressed on disk D)

  1. Common compression: ajaxmin D: \ demo. js has little effect. It is not recommended for use. Learn more;
  2. Advanced compression: ajaxmin D: \ demo. js-o d: \ demo1.js compress demo. js and convert it to demo1.js and save it in the root directory of drive D. The effect is obvious and recommended;
  3. Super compression: ajaxmin-h d: \ demo. js-o d: \ demo2.js. After super compression of demo. JS, convert it to demo2.js and save it in the root directory of drive D. The effect is remarkable and is strongly recommended;

When you press enter to execute the command, the crunching file 'demo. js '... The done. text indicates successful. At the same time, the root directory of the d disk will contain multiple demo1.js or demo2.js files.

Some friends will find that the size of the files after the two compression methods is not much different, that is, about 2 K. Here we want to explain why. When the-H (hyper-crunching) command is used, you will find that some regional commands are renamed to simple names, such as VAR exists --> var, therefore, the number of bytes will be less, but the effect will not be discounted. We don't have to worry about its principle, so it's easy to use.

Step 3: Rename the compressed JS file and overwrite it to the server. Of course, the backup work is also required. When there is no problem with the test, you can delete the original bloated files.

We will use the latest jquery 1.3.2 for an experiment. The official website is here. Two official versions are available, one mini version, which is 57253 bytes in size. The full version is 120763 bytes in size. Use
The size of the-H parameter is 55860 bytes for the mini version. The full version is 55863 bytes, Which is compressed in most cases. The effect is remarkable.

Extended reading: all the friends who are playing Wordpress are trying their best to make loading faster and the Capacity smaller. There are also many other JS compression methods online, such as online compression. Try the effect here. You will find that the efficiency is far from Microsoft
Ajax minifier is good. The above full version is 73285 bytes after super compression, which is a gap. After all, Microsoft has a certain degree of technical knowledge, or it will not be able to provide ugly information. :-)

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.