Optimization- Is there any way to find and remove unused CSS and Javascript common to all html pages?

HackCode picture HackCode · Feb 13, 2015 · Viewed 30.3k times · Source

My website has many webpages and I am trying to clean up my stylesheets and scripts. About 10% or more of each js/css are not being used by any of the html pages in my website. What I need is to remove the common unused and redundant css and js. I did a bit of research and found this. But it is not free.
NOTE:

  • Some of the js/css are being called by more than one html page and still there is a portion of each js/css not being used by any of the html pages which are calling them.
  • My website is only compatible in Chrome.

Answer

codeepic picture codeepic · Feb 13, 2015

Yeah, you should use Addy Osmani's grunt-uncss plugin to clean up unused CSS. I am not so sure whether you can use a tool for removing unused JS, since it depends on application logic, which part of JS code will be called.