News for hackers. Stuff that matters.
Re:Ask HN: How do you find unused CSS? by debacle on Monday March 21, 2016 @09:11AM (#11327801)
How dynamic is your application? The answer is heavily dependent. If your application is mostly static, you can just use a tool that can convert CSS selectors to XPath selectors and scan your site for those elements. If your site is highly dynamic, the solution is much more difficult and likely involves a certain level of browser automation.
Re:Ask HN: How do you find unused CSS? by brianwawok on Monday March 21, 2016 @10:19AM (#11328189)
What kind of tools do you suggest?

Google shows me:

https://davidwalsh.name/uncss (I think for dynamic)

https://unused-css.com/ (I think also works for dynamic)

and a bunch more

Re:Ask HN: How do you find unused CSS? by debacle on Monday March 21, 2016 @12:39PM (#11329328)
You could write a clever script in 50-100 lines. Most languages have css to xpath libraries.
Re:Ask HN: How do you find unused CSS? by Someone on Wednesday March 23, 2016 @04:19PM (#11347863)
Even that isn't as simple as it seems. Your site may have h3 elements, but that does not mean that your h3 rule will be used. Maybe all of your h3 elements are covered by more specific rules, such as ones checking for h3 in a div, or for h3 followed by a p.
Re:Ask HN: How do you find unused CSS? by tmaly on Monday March 21, 2016 @10:39AM (#11328342)
initially I would start with a static layout. I would want to optimize the css and what is actually used for both desktop and mobile. After that, I would convert the static layout to a dynamic template.