TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Know of a good tool that finds unused stylesheet selectors and rules?

7 点作者 apphacker将近 15 年前
It seems to be a common problem that as stylesheets mature and the project grows that eventually you may end up in a situation where you are not sure if various styles are still being applied anywhere. Does anyone know of a good way to figure this out with some kind of software tool?

3 条评论

jacquesm将近 15 年前
You can't really be sure without running all of your javascript code and checking all of your pages, after all some hidden bit of javascript might change a style based on some event to match one in the css, it might even do it by combining various terms to form the selector, and it might manipulate the ids and classes of elements already on the page.<p>That's a tricky problem. I'm not aware of a tool, but if you find one I'll be happy to test it, I have a few of those questionable items in my style sheets that are still there 'just in case'.
评论 #1405498 未加载
rarestblog将近 15 年前
Google Chrome. Ctrl+Shift+J, Audits tab, Run...
评论 #1405681 未加载
tamersalama将近 15 年前
There's a firefox plugin. <a href="https://addons.mozilla.org/en-US/firefox/addon/5392/" rel="nofollow">https://addons.mozilla.org/en-US/firefox/addon/5392/</a> It has been a while since I last used it but it generally gave good indications.