javascriptjquerylegacy-codecode-cleanup

How to find out if certain javascript code is actually used?


I am doing some JavaScript cleanup work on a legacy project, and trying to get rid of redundant JS libraries. I have done all the obvious ones (those that are not references from anywhere at all). But there are a number of JS files that are included in all pages (via tiles).

How can I find out whether they are actually used, short of going through content of each and search for each function in them? Is there a smarter/easier way to do this? It's a java based / Spring project if that helps by the way.


Solution

  • I think there's no easy way.

    You can remove the script reference, run your site with the browser debugger turned on, and see if there's any "function not found" error.

    But you'll have to test every single functionality in your site...


    EDIT:

    The answer from user li x seems to be the best at this moment.