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?
If your website is running on WordPress, you can remove the unused JavaScript from its pages using special plugins. For example, you can use AssetCleanUp, which also allows you to disable unused JavaScript files. Another option is to detect unused JS with Chrome DevTools and delete unnecessary files.
Here are some reasons why unused code should be removed: For anyone new working on a project, they not only have to understand the working code, they have to understand unused material also. This is wasted time and creates confusion.
The quickest way to find dead code is to use a good IDE. Delete unused code and unneeded files. In the case of an unnecessary class, Inline Class or Collapse Hierarchy can be applied if a subclass or superclass is used. To remove unneeded parameters, use Remove Parameter.
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
Have a look at this question regarding Javascript static analysis tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With