Reputation: 14318
I did find a very interesting tool for identify unused css definitions in a web project. http://www.sitepoint.com/dustmeselectors/
Are there similar tools also for javascript projects?
P.S. I know there is no program for deterministically finding unused code. But I am looking for a report to identify possible unused code. Then the last decision will always be your own.
Upvotes: 10
Views: 11770
Reputation: 2524
In order to find the unused assets, to remove manually, you can use deadfile library: https://m-izadmehr.github.io/deadfile/
It can simply find unused files, in any JS project.
Without any config, it supports ES6, JSX, and Vue files:
Upvotes: 2
Reputation: 31
You can try using tombstones to safely locate and remove dead code from your JavaScript.
https://blog.bugsnag.com/javascript-refactoring-with-bugsnag-and-tombstones/
Upvotes: 3
Reputation: 1539
Problem is there is no way to be really sure. Suppose the following:
Static analysis utilities are therefore useless. I do not know whether there exists a browser extension that marks all JS usage from a running browser though.
Upvotes: 7
Reputation: 1179
The one that comes to mind most quickly is Javascript LINT (http://www.javascriptlint.com/) and JSLint (http://www.jslint.com/).
Beware though: the latter hurts your feelings.
Upvotes: -7