find unused images, css rules, js script blocks

Viewed 45721

We have a fairly large asp.net website.

The images, css and javascripts are property organized in the website project but as we are changing the look and feel of the website, I would like to know if there is a tool/add-in that will help me identify which images are not being used in the website.

I would like to find the same thing with css and javascript as well. I have looked at dustme firefox extension but that only does css.

5 Answers

Unused CSS

  1. Take a look at the Firefox extension Dust-Me at http://www.sitepoint.com/dustmeselectors/.

  2. Google Chrome has a website auditing tool in their developer console.

  3. Also I found this site for removing unused css - http://unused-css.com/ . Type the url of a site and you will get a list of CSS selectors. For each selector, a number indicates how many times a selector is used. This service has a few limitations. The @import statement is not supported. You can't configure and download the new clean CSS file.

  4. Helium CSS is a javascript tool for discovering unused CSS across many pages on a web site. You first have to install the javascript file to the page you want to test. Then, you have to call a helium function to start the cleaning.

  5. CSSESS is a bookmarklet that helps you find unused CSS selectors on any site. This tool is pretty easy to use but it won't let you configure and download clean CSS files. It will only list unused CSS files.

  6. How can I find unused images and CSS styles in a website?

Unused Images:

  1. http://obsidience.blogspot.in/2008/06/using-powershell-to-find-unused-images.html
  2. How Do I Make a Bash Script To Find Unused Images in a Project?

Unused JS:

  1. Find unused CSS rule and js script in a web project?
  2. Find unused Javascript functions?

One possible approach would be:

  1. to use your browsers save-for-offline functionality and do an entire download of the site and all its resources to a local folder.
  2. Then run a little perl script that will slurp up all the *.{jpg,png,gif...etc}
  3. then do a diff on the list when you run it from your project source directory.

Obviously there are some limitations to this approach but if its all you have it might be a good start!

I never had luck with any browser extensions that claim to do just that.

I run a console app that relies on AgentRansack to find unused css classes in the project directory (i.e. declared but not referenced in ascx/js etc.) - then it merges the results into a usage report. I'm assuming this could be fairly easily adjusted to look for image srcs etc., as long as the project directory has unused pages removed.

Is there demand for a properly distributed tool like that?

Server will not open unused files, so you can check last access time. Right?

Related