Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting only the css used in a specific page

Tags:

css

Say you had a dynamically generated site that has been worked on by too many people, past and present, and you now have a collection of shared stylesheets that contain over 20,000 lines of CSS. It isn't organized at all, there are some class and id-based selectors but also way too many tag-based selectors. And then say you have 100 templates that use these styles, via some controller.

Is there a tool, something that works like Firebug perhaps, that you can point at a url and it would determine all of the applicable CSS selectors for that page and dump them to a file? Basically some way to rip apart the shared stylesheets on a page by page basis.

like image 770
Roger Halliburton Avatar asked Feb 01 '11 19:02

Roger Halliburton


People also ask

How do I eXtract the CSS code from a website?

Install "eXtract Snippet"=> Inspect an element using chrome's developer tools 'inspect element'. Within the developer tools you should also see a panel named "eXtract HTML CSS". Click on to the "eXtract HTML CSS" panel and further click onto the "Get HTML/CSS of inspected element" button withing the panel.

How do I find the CSS of a page?

On Chrome's Developer Tools tab (CTRL + SHIFT + I), go to Resources (you may have to enable Resource tracking on that page), and click on the sub-tab Stylesheets. That will show all css files loaded by that page.

How do I know what CSS is being used?

😬 Looking at “coverage”Chrome's DevTools has a “Coverage” tab that will tell you how much of your CSS and JavaScript is in use. For example, if I visit the homepage of CSS-Tricks right now… It tells me that 70.7% of my style. css file is unused.

How do I download all CSS files from a website?

Open up the webpage and click File-> Save Page As... and from that prompt select "Web Page, Complete" . Once you've saved this page this downloads a complete version of the html, javascript, css files and images that are referenced in the HTML.


1 Answers

Hands down the best tool that actually does exactly what you want by only getting the used CSS on the page and allows you to simply copy it to your clipboard is this Chrome extension CSS Used

Pretty Picture Example

enter image description here

like image 136
Cesar Bielich Avatar answered Oct 16 '22 10:10

Cesar Bielich