44

I have around 100 .js files in my application. I need to find the unused functions from these files.

Which editor or tool can help me?

zombat
  • 92,731
  • 24
  • 156
  • 164
user143442
  • 449
  • 1
  • 4
  • 3
  • 1
    I dont' this there is a way to do it completely. Check this question : http://stackoverflow.com/questions/1167663/is-there-a-tool-to-remove-unused-methods-in-javascript – Shoban Jul 23 '09 at 06:58
  • Possible duplicate of [Is there a tool to remove unused methods in javascript?](https://stackoverflow.com/questions/1167663/is-there-a-tool-to-remove-unused-methods-in-javascript) – aug May 15 '18 at 18:37

3 Answers3

9

Give a look to the JSLint code quality tool.

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471
Christian C. Salvadó
  • 807,428
  • 183
  • 922
  • 838
1

You can do this using Jsure, a Javascript lint implementation. You'll be looking for the -unused-funs flag

JohnnyHK
  • 305,182
  • 66
  • 621
  • 471
0

Necromancing for the sake of completeness:

On the frontend you can now use modern browsers' devtools, which now have the "Coverage" tab (at least Chromium-based do).

This tab allows you to "record" user activity for some time and then inspect which parts of JS files haven't been called/executed. Works for CSS too.

In dev tools press Ctrl + Shif + P to bring up the command bar, start typing "Cover.." and the "enable Coverage tab" will pop up. Then press "record" at the bottom area.

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149