Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.
like image 906
HackCode Avatar asked Feb 13 '15 10:02

HackCode


People also ask

How do I find unused CSS sites?

The Coverage tab in Chrome DevTools can help you find unused JavaScript and CSS code. Removing unused code can speed up your page load and save your mobile users cellular data.

How optimize CSS and JS file?

Using CSS Minifier CSS Minifier is a free and simple tool that automatically compresses CSS assets. All you need to do is paste the code into the input field, set a compression level, and click "Minify." Depending on the size of your code, it may take a few seconds to a minute to minify your code.


1 Answers

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.

like image 121
codeepic Avatar answered Sep 20 '22 03:09

codeepic