简体   繁体   English

如何最小化和结合Javascript和CSS

[英]How to minify and combine Javascript and CSS

Can someone give me pointers on how I can minify and combine my CSS as the site I'm working on has performance issues. 当我正在工作的网站出现性能问题时,有人可以向我指出如何缩小和组合CSS。 Also, are external JS and CSS libraries also minified and combined or left as is? 另外,外部JS和CSS库是否也已缩小和组合或保持原样?

There are several convenient options for .NET, for example: .NET有几个方便的选项,例如:

Chirpy

SquishIt 挤压

Cassette 暗盒

And new in ASP.NET 4.5: Bundling in ASP.NET 4.5 ASP.NET 4.5中的新增功能:ASP.NET 4.5中的捆绑

我建议阅读Google的Page Speed及其Closure Compiler Service

I would also add RequestReduce for .net options. 我还将为.net选项添加RequestReduce It may be the only runtime bundling option for minifying external resources. 它可能是最小化外部资源的唯一运行时捆绑选项。 Its unique from the other .net options in that it grabs the unminified content via http instead of via the file system. 它与其他.net选项的不同之处在于,它通过http而不是通过文件系统捕获未缩小的内容。 It can also sprite your background images. 它还可以显示您的背景图像。

I know this is an old question but I thought I will give a better answer (trick). 我知道这是一个老问题,但我认为我会给出一个更好的答案(技巧)。

In visual studio if you do format code (Ctrl + K + D) then css will be formatted nicely for you. 在Visual Studio中,如果您执行格式代码(Ctrl + K + D),则CSS会很适合您的格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM