How to remove dead code from Javascript [duplicate]

人走茶凉 提交于 2019-11-29 11:39:05

问题


This question already has an answer here:

  • find dead JavaScript code? 8 answers

I am trying to remove unused functions from my project. Since it has thousands of lines, this takes forever.

Code coverage tools may suggest functions that are not used in a given test case, but it may be dangerous to rely only on this.

Is there another tool which can help with this?


回答1:


You can try Google Closure compiler. It has different settings and you can also remove dead code automatically. You can try it here: http://closure-compiler.appspot.com/home

For more info read here: http://code.google.com/closure/compiler/docs/compilation_levels.html




回答2:


Have a look at this question regarding Javascript static analysis tools.



来源:https://stackoverflow.com/questions/6730358/how-to-remove-dead-code-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!