Question

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?

Was it helpful?

Solution

JavaScriptCompressor is not thread safe and should be recreated upon use (it stores state). CssCompressor does not store state.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top