How to compress JS and CSS files

Source: Internet
Author: User

compression : Removes all comments, tick marks, line breaks, and useless spaces in Javascript code, compressing the JS file size.

How JavaScript files are compressed

The first, of course, is to remove the comment .

The other is the same as the CSS compression to remove line breaks , spaces or something.

JavaScript has several variable forms, such as variables, function names, function parameters, and so on, usually when we write JS code, in order to facilitate understanding, we will give these variable names with intuitive strings, such as: Var title= "JavaScript", this habit is worthy of praise.

However, these variables are helpful to the user's understanding, and to the computer, if we turn the previous sentence into: Var a= "JavaScript", it is the same for the computer.

Usually deep compression JS must do a step is to shorten the variable name as much as possible , because a large volume of JS code, where the variable name will occupy a lot of space.

How to compress JS and CSS files

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.