Is there any way to remove unused CSS and JS code from the application?

5

I wonder if there is an transpiler that parses the classes and ids used in an HTML page and removes all classes and ids in CSS and JavaScript.

This would be interesting to further narrow down files by improving page performance.

    
asked by anonymous 13.12.2018 / 12:02

1 answer

6

As you said that a "small-scale" solution also suits you, I'll give you a tip using the Aba Coverage of DevTools of Chrome. Google Link link

In Aba Coverage you can evaluate what code is actually in use, worth both CSS and JS. I left the comments in the image.

ThedetailisthatforexampleresponsiveCSSisonlymarkedGreenwhenitisactuallyactivated.Thisistheonlydrawbackofthistechnique,becauseyouhavetonavigatethepagetoseewhatisusedornot.NotethatasIsaidthereisno<h1>inHTML,thentheCSSruleof<h1>willneverturnGreen



Seethisotherimagewithalargerdocument!



AsIsaid,itisnottheperfectsolutionforlargeprojects,butifitisusedfromthestartandauditingrightinshortperiodsoftime,itispossibletocontrolwellwhatisactuallybeingusedandwhat"junk" is. ..



EDIT How to open ABA COVERAGE



ChromeExtension

IntheChromeWebStoreyou'llalsofindsomeextensionsthathelpyou link

    
13.12.2018 / 13:00