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.
Open up the page in chrome, right click on the page and select inspect element (or press ctrl+shift+I). From there you can navigate the different elements on the the page and the structure of the HTML file.
Chrome. Open Chrome and navigate to the web page containing the JavaScript you want to view. Right-click an empty area on the web page and select Inspect in the pop-up menu to open the Chrome developer tools.
A simple way to see what files are downloaded is to hit F12 in Internet Explorer to open up the Developer Tools. Then go to the Network tab, refresh the page and you'll see the requests made.
One of the latest updates from the chrome dev tools now includes a JS and CSS coverage tab that allows you to see your unused code.
https://developers.google.com/web/updates/2017/04/devtools-release-notes
1) Open the Command Menu. 2) Start typing Coverage and select Show Coverage.
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