Alan Alan - 1 year ago 83
Javascript Question

Is there a tool to remove unused methods in javascript?

I've got a collection of javascript files from a 3rd party, and I'd like to remove all the unused methods to get size down to a more reasonable level.

Does anyone know of a tool that does this for Javascript? At the very least give a list of unused/used methods, so I could do the manually trimming? This would be in addition to running something like the YUI Javascript compressor tool...

Otherwise my thought is to write a perl script to attempt to help me do this.

Answer Source

No. Because you can "use" methods in insanely dynamic ways like this.

obj[prompt("Gimme a method name.")]();