Home >Web Front-end >JS Tutorial >Discussion on js compression and jquery compression (improving page loading performance/protecting labor results)_javascript skills
Discussion on js compression and jquery compression (improving page loading performance/protecting labor results)_javascript skills
- WBOYOriginal
- 2016-05-16 17:42:43995browse
Cause of the problem: I am responsible for the research and development of the company's development platform. When considering the protection of intellectual property rights, I must consider the encryption technology of java and the encryption technology of js scripts. In the current situation where Java encryption is easy to crack, it is better to deal with the encryption and compression of JS first. On the one hand, it can improve the page loading performance. On the other hand, we also hope that the results of hard research and development will be protected to a certain extent.
Research process:
1. First of all, I would like to strongly despise those guys who casually reprint articles, which have caused a lot of trouble for me! ! Many posts online are unreliable. .
2. First of all, I wanted to know what kind of compression jquery uses. I searched online for a long time and found different opinions. Later, I found the answer in the most frequently asked questions on jquery official website, but this was already a big detour. .
(a) According to some information I have seen, jquery compression was first compressed using Dean Edwards' Packer, probably in jquery 1.3 version (I read it in a jquery book.). This thing came out relatively early, and the author seems to be a great person. It is currently version 3.0, which seems to be an online version. I compressed the code on his website, but it cannot be used and errors will occur.
(b) Later, jquery was replaced with yuicompressor for compression. The specific version is not clear. The author of an article said: He searched in the svn of jquery and found that there are yuicompressor files, and then he specifically used jQuery. js tried it, and the processed files were exactly the same as jQuery.min.js. Original post address.
(c) Oh my god, finally I found this paragraph on the jquery official website. How do I compress my code?
The content is as follows:
Generally the best way to do it is to use the Google Closure Compiler (used by jQuery) or YUI compressor. jQuery provides a pre-minified version of jQuery for your convenience.
Packing JavaScript using Dean Edwards' Packer (specifically using the base64 encode) is not recommended, as the client-side decoding has significant overhead that outweighs the file-size benefits.
The general meaning is: jquery uses Google’s open source js compression tool. Google Closure Compiler and YUI compressor are currently the best js compression methods. Dean Edwards' packer is not recommended!!
Afterthoughts:
1. In fact, I have noticed the Google Closure Compiler tool for a long time, but I was influenced by a netizen. Misleading, didn’t try it. He gave two reasons. One is that this thing has not been open source for long, and the other is that it will rewrite and optimize your code structure and currently has several serious problems; I was looking for what compression tool jquery uses. Technical articles like TMD written by Chinese people are not trustworthy, and they are copied everywhere! ! For many things, you have to read the documentation on the official website.
2. Google is a great company, and its technology is very cutting-edge. YUI was developed by Yahoo before. Yahoo has performed poorly in the past few years. I think Google has absorbed many technical experts in the current IT field. We should believe that Everything it produces is top quality.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn