0

I've inherited a project where the pages have close to hundreds of includes. Every little piece of functionality was broken out by file.

Is there a way to find out which script includes are not used? I know there is a way to find dead methods via grep, but it's a slow and error prone.

Ideally, I'd like to feed the URL to a resource that would identify dead includes. Is something like this possible?

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • Assuming the scripts all contain only a few functions, you could just search for those functions in the whole project to see if they're referenced at all. Or you could just go at it aggressively and remove the reference to the file itself, and see if the functionality breaks :P – Obsidian Age Jun 14 '18 at 00:24
  • so a "dead include" is a file that isn't included anywhere? so `feed the URL to a resource that would identify dead includes` won't identify files that **are not** included, it would identify files that **are** included – Jaromanda X Jun 14 '18 at 00:29
  • 1
    If these files are in a linux system, you can possibly use the "file access time" to see which files are not being accessed - windows, https://serverfault.com/questions/351777/how-can-i-know-when-a-file-was-last-read-or-accessed-on-windows may help – Jaromanda X Jun 14 '18 at 00:32
  • @JaromandaX That won't work unfortunately because the browser still brings the file in and compiles the code within. The file just might not be used by anything. – AngryHacker Jun 14 '18 at 19:09

1 Answers1

2

The rollup bundler has a treeshake feature which will omit any unused function from it's output bundles. See the treeshake documentation

You might be able to fork and mod the source code to output the omitted functions if you so desire.

varontron
  • 1,120
  • 7
  • 21