开发者

time yahoo yui takes to compress css

I am using the Yahoo Yui Compressor to compress my css styles. I reference the dll in my c# application and make the call to the compressor as follows:

CssCompressor.Compress(fileContent, 0, CssCompressionType.StockYuiCompressor)

This worked perfectly up to recently.

开发者_运维知识库Over recent days, the size of my stylesheets have increased from 7KB to 130KB. The reason for this is the inclusion of base64 data uri's within the stylesheets instead of image requests. As a result of this, the compressing of the css has gone from ~1 seconds to +10 seconds.

This has become an issue for me, as this is a long period of time to wait for each of my stylesheets to compress.

Using Yahoo Yui, is there anyway to speed up the compressing?

Or do I need to move another css minifier/compressor?


You can try Microsoft's Ajax Minifier, which has a simple .NET API. In my tests it compressed better than the YUI Minifier.

Regardless of the minifier you should try caching the minified stylesheets instead of recomputing on every request, and prime the cache on application startup. Your startup time may be long but it won't affect each request.

Recompute if necessary. For example, if a file changes on disk and you want to update you can use a CacheDependency when inserting the minified CSS into the cache.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜