JavaScriptCompressor
is not thread safe and should be recreated upon use (it stores state). CssCompressor
does not store state.
JavaScriptCompressor, CssCompressor and multi threading
-
29-07-2022 - |
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?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow