对 CSS minifier 有什么推荐吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/787789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:32:24  来源:igfitidea点击:

Any recommendations for a CSS minifier?

cssminify

提问by Paul D. Waite

Any recommendations for a CSS minifier?

对 CSS minifier 有什么推荐吗?

I'll be rooting around Google and trying some out, but I suspected that the smart, proficient and curiously handsome StackOverflow community might have already evaluated the pros and cons of the heavyweights.

我会在谷歌周围扎根并尝试一些,但我怀疑聪明、熟练和奇特英俊的 StackOverflow 社区可能已经评估了重量级的利弊。

采纳答案by Buddy

The YUI Compressoris fantastic. It works on JavaScript and CSS. Check it out.

锐压缩机是太棒了。它适用于 JavaScript 和 CSS。一探究竟。

回答by Pure.Krome

There's also a .NET port of YUI Compressorwhich allows you to:-

还有一个 YUI Compressor 的 .NET 端口,它允许您:-

  • intergrate the minification/file combining into Visual Studio post-build events
  • intergrate into a TFS Build (including CI)
  • if you wish to just use the dll's in your own code (eg. on the fly minification).
  • 将缩小/文件组合集成到 Visual Studio 构建后事件中
  • 集成到 TFS Build(包括 CI)中
  • 如果您只想在自己的代码中使用 dll(例如,即时缩小)。

UPDATE 2011: And it's now available via NuGetalso :)

2011 年更新:现在也可以通过 NuGet 获得:)

回答by artlung

I like Minify. In PHP and works with CSS or JavaScript.

我喜欢缩小。在 PHP 中使用 CSS 或 JavaScript。

回答by silent

CSSOis currently best minifier/optimizer.

CSSO是目前最好的缩小器/优化器。

回答by Peter Bengtsson

If you use Python I would recommend slimmerwhich is probably not as fast as YUI Compressor but unlike csscompressor.net it doesn't choke on CSS hacks.

如果您使用 Python,我会推荐slimmer,它可能不如 YUI Compressor 快,但与 csscompressor.net 不同,它不会被 CSS hacks 阻塞。

I'm biased since I wrote slimmer and I'm currently evaluating YUI Compressor to see how it handles hacks. An example of slimmer in action can be seen if you view the source of crosstips.org

我有偏见,因为我写得更苗条,我目前正在评估 YUI Compressor,看看它如何处理黑客攻击。如果您查看 crosstips.org 的来源,可以看到一个更苗条的例子

回答by miguelSantirso

If you are looking for an online tool, try this: https://csscompressor.net/

如果您正在寻找在线工具,请尝试以下操作:https: //csscompressor.net/

回答by Kerido

I've written an ultra fast CSS minifier in C#. The algorithm does not handle Javascript though. Thy this: http://www.ko-sw.com/Blog/post/An-Ultra-Fast-CSS-Minify-Algorithm.aspx.

我用 C# 编写了一个超快的 CSS minifier。虽然该算法不处理 Javascript。你这个:http://www.ko-sw.com/Blog/post/An-Ultra-Fast-CSS-Minify-Algorithm.aspx

回答by Andrzej Du?

Try closure-stylesheets.

试试闭包样式表

Beside minificationit also supports linting, RTL flipping, and class renaming.

除了缩小,它还支持lintingRTL 翻转类重命名

It can also add variables, functions, conditionals, and mixinsto CSS.

它还可以向 CSS添加变量函数条件混合

Also note that some of these features depend on rest of Closure Tools(which are very powerful on their own).

另请注意,其中一些功能依赖于Closure Tools 的其余部分(它们本身就非常强大)。

回答by bcosca

If you're looking for something in PHP, here's the link:-

如果您正在寻找 PHP 中的内容,请访问以下链接:-

Fat-Free Minify

无脂肪缩小

Although it's part of the PHP Fat-Free Framework, it can also be used stand-alone.

虽然它是 PHP Fat-Free Framework 的一部分,但它也可以独立使用。