9

I'm working on an upgrade for our current application (asp.net mvc). Here my problem is, I have a existing css file name "styles.css". Now this file has lots of css classes and they are used in different pages.

Now as a part of the upgrade process, this css file will not be used anymore. But I still want certain css classes from this file, so that I can copy them to a new file and include it in my pages.

Any ideas on how to extract these styles which are used in my new pages. And yes the styles which I want to pick are already set to the controls in the page. Please help.

1

4 Answers 4

10

Finding ones that are used in single page should be easy with multiple tools. One good tool is called UnCSS.

The trick is checking an entire site where CSS file is shared accross pages.

This approach was popular in social networks recently with some high profile guys sharing it like Google's Addy Osmani and some Google Chrome guys:

http://addyosmani.com/blog/removing-unused-css/

Sign up to request clarification or add additional context in comments.

Comments

6

Use Chrometools Audits

In Chrome Press: F12 -> Audits -> Run

It will let you know what is and is not used.

Chrome Audits

3 Comments

Is there a way to access this programmatically?
@Gajus from what context? Do you mean as a browser extension or as an external website accessed by the client? I am somewhat hopeful that a website I access cannot run an audit on my machine without my permission. If from an extension context, I believe so. See: chrome.experimental.devtools.audits
True. Website being able to run the audit could be a risk. I am primarily interested in the Chrome DevTools protocol, though. reddit.com/r/javascript/comments/6lvov7/…
1

There are a lot of ways, for example:

Comments

-1

Use a Browser Debugger, click on the elements on site and see on the right corner which classes are machtes and copy them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.