Home > Web Front-end > JS Tutorial > body text

What is the difference between .min.js and .js files in javascript?

不言
Release: 2018-03-30 17:24:45
Original
4199 people have browsed it

This article will share with you the difference between .min.js and .js files in javascript. If you have friends who don’t know the difference between the two, you can take a look at

Q&A

Q: What are .js and .min.js files?
A: .js is a JavaScript source code file, and .min.js is a compressed version of the js file.

Q: Why should it be compressed into a .min.js file?

  • Reduce size
    The .min.js file is compressed, smaller in size than the js file before compilation, and has fast transmission efficiency.

  • Prevent peeking and stealing the source code
    After coding, the original names of variables and functions are changed to meaningless names to prevent others from peeking and stealing the js source code

Q: What are the advantages and disadvantages of .js and .min.js files?

.js文件:
  优点: 可读性较好,易于debug和更改.
  缺点:体积较大,传输时间长
  
.min.js文件:
  优点:体积较小传输快, 源码防窃
  缺点:可读性差
Copy after login

Q: How to generate .min.js file?
Use compression tools:

Google的在线版本 Javascript Closure Compiler 
压缩工具参考list:  [http://www.cnblogs.com/lhb25/p/15-best-javascript-minifying-tools.html][1]
Copy after login

Q: Compression principle?

  • Compression: Remove all comments, tabs, line breaks and useless spaces in the js code, thereby compressing the JS file size.

  • Obfuscation: Change the original names of variables and functions to meaningless names through coding, delete useless code, inline functions, equivalent statement replacement, etc. (to prevent others from peeking and stealing Source code)

Related recommendations:

php object-oriented detailed explanation of the differences between private, protected, and public

What is the difference between @HostBinding() and @HostListener() in AngularJS

The difference between method and computed in Vue

The above is the detailed content of What is the difference between .min.js and .js files in javascript?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!