1. With the popularization of Ajax applications, JavaScript has received more and more attention from programmers
2. JS is not easy to debug, and too much code will seriously affect the speed. When you are happy to improve the user experience and create brilliant effects, have you ever thought about optimizing the efficiency of JS? The JS of large websites have been compressed.
3. The speed of JS is divided into two types, download speed and execution speed. If you want to download JS quickly, you need to reduce the size of the JS file as much as possible. In addition, merging multiple JS files into one can also speed up web page downloads by reducing the number of server responses.
4. You can encode the variable names and process names of Javascript to encrypt the Js code and protect the success of your work.
Basic principles of JS code compression
1. Compress extra spaces and newlines
2. Delete comments, because comments are only useful to programmers and are useless to end users browsing web pages. Deleting them can reduce the file size.
3. Replace long variable names and procedure names with short names. This can reduce the size of the program and reduce the readability of the program to protect your own success.