简体   繁体   English

优化/缩小 javascript 代码但仍然可读/可维护

[英]optimized/minifed javascript code but still readable/maintainable

I'm a beginner at javascript and learn a lot by looking already written code.我是 javascript 的初学者,通过查看已经编写的代码学到了很多东西。

Some large javascript projects I've looked at have minified code and when expanding it it's not very readable.我看过的一些大型 javascript 项目具有缩小的代码,并且在扩展它时它不是很可读。

almost all variables and functions are just defined by a letter looping trough the alphabet ie ab c, aa, bb, cc and so on, also no commenting.几乎所有的变量和函数都只是通过字母循环定义,即 ab c、aa、bb、cc 等,也没有评论。

Out of curiosity is this a coding style or is there a tool that you use to optimize the code with?出于好奇,这是一种编码风格,还是有用于优化代码的工具?

seems hard to maintain such a project.似乎很难维持这样的项目。

No, it's not a coding style (except if you're doing code-golfing manually for fun).不,这不是一种编码风格(除非你为了好玩而手动打代码)。

You take the unminified code and squeeze it through a tool such as https://github.com/terser/terser (which is probably the most popular at the time of writing).您获取未压缩的代码并通过https://github.com/terser/terser (这可能是撰写本文时最流行的工具)之类的工具对其进行压缩。

You can see what Terser does online with their Try Terser tool.您可以使用他们的 Try Terser 工具在线查看 Terser 所做的事情。 https://try.terser.org/ https://try.terser.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM