2

I'm using a static class to wrap the Yahoo YUI compressor:

public static class Minifier
{
    private static readonly ICompressor javaScriptCompressor = 
                                                   new JavaScriptCompressor()
    {
        CompressionType = CompressionType.Standard,
        IgnoreEval = true,
        ObfuscateJavascript = true,
        PreserveAllSemicolons = true
    };

    private static readonly ICompressor cssCompressor = new CssCompressor()
    {
        CompressionType = CompressionType.Standard,
        RemoveComments = true
    };

    public static string GetCompressedCss(string data)
    {
        //aaaand... action
        return cssCompressor.Compress(data);
    }
}

I was wondering if the compressor classes are thread save?

4

1 回答 1

0

JavaScriptCompressor不是线程安全的,应该在使用时重新创建(它存储状态)。CssCompressor不存储状态。

于 2013-11-22T15:49:34.330 回答