...
No big intellectual mystery about what refactoring is.
For code what does a well labeled folder look like? Best way I have found is name based prefixes.
For example if you had a function in a screen that was related to say “search”. It might involve putting all the functionality related to this function in:
A directory named SEARCH (assuming there are no other functions in the software taking that folder) (there isn’t a universal filing system for software)
Name the files like image files, SVG files, CSS files, Javascript files and HTML templates to use the SEARCH prefix and be inside of the SEARCH folder
Keep the hierarchy flat - don’t have folders inside the SEARCH folder (we’re assuming we aren’t running a software project on the scale of Google)
Name all the CSS classes, function names, variables, values stored in a global areas like local storage with the SEARCH prefix.
After this is should be quite easy to find all the dependencies and avoid the accumulation of dead code.
Another good analogy is IKEA - it makes sense to group a set of screws, boards, knobs etc. based on a piece of furniture - rather than separating the individual parts.