热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

仅提取特定页面中使用的css-Extractingonlythecssusedinaspecificpage

Sayyouhadadynamicallygeneratedsitethathasbeenworkedonbytoomanypeople,pastandpresen

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.

假设您有一个动态生成的网站,过去和现在都有太多人使用,现在您拥有一组包含超过20,000行CSS的共享样式表。它根本没有组织,有一些类和基于id的选择器,但也有太多基于标签的选择器。然后说你有100个模板使用这些样式,通过一些控制器。

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.

是否有一个工具,可能像Firebug一样工作,您可以指向一个URL,它将确定该页面的所有适用的CSS选择器并将它们转储到文件中?基本上是一种逐页拆分共享样式表的方法。

11 个解决方案

#1


18  

I've used Dust-Me Selectors before, which is a Firefox plugin. It's very easy to use and versatile as it maintains a combined list across a number of pages of which CSS values are used.

之前我使用过Dust-Me选择器,这是一个Firefox插件。它非常易于使用和通用,因为它在使用CSS值的多个页面中维护组合列表。

The downside is that I wasn't able to automate it to spider an entire site, so I ended up using it just on key pages/tempates of my site. It is very useful nonetheless.

缺点是我无法自动化它来蜘蛛整个网站,所以我最终只在我网站的关键页面/模板上使用它。尽管如此,它仍然非常有用。

http://www.sitepoint.com/dustmeselectors/

http://www.sitepoint.com/dustmeselectors/

https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/

https://addons.mozilla.org/en-US/firefox/addon/dust-me-selectors/

Contrary to the comment above Dust-Me Selectors 2.2 is compatible with Firefox 3.6 (I've just installed it).

与上面的评论相反,Dust-Me Selectors 2.2与Firefox 3.6兼容(我刚安装它)。

#2


16  

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

通过仅在页面上获取使用的css并允许您将其简单地复制到剪贴板并将其粘贴到此Chrome扩展程序CSS使用,实际上完全符合您的要求

Pretty Picture Example

漂亮的图片示例

#11


0  

Check for PurifyCSS, and this for those who can handle CLI or Gulp/Grunt/Webpack

检查PurifyCSS,以及那些可以处理CLI或Gulp / Grunt / Webpack的人

You can remove the unused style from single page or multiple page or from the entire project, even thought the classes are being injected by Javascript.

您可以从单个页面或多个页面或整个项目中删除未使用的样式,甚至可以认为这些类是通过Javascript注入的。

If you can google, there are tons of resources out there from which you can learn about PurifyCSS.

如果你可以谷歌,那里有大量的资源,你可以从中了解PurifyCSS。


推荐阅读
author-avatar
晴可倾
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有