Different Compression Options

Mar 25, 2011 at 8:47 AM
Edited Mar 25, 2011 at 9:34 AM

Hi purekrome,

I've just used your YUI Compressor for .NET 1.5.0.0 . Congrats on the fantastic work you've done, excellent job!

As I go along the YUI-way, I'm trying several options for setting a different compression-type, but I'm wondering what are the changes in these types?

edit: The Types I'm talking about are:

YuiStockCompression | MichaelAshsRegexEnhancements | HaveMyCakeAndEatIt or BestOfBothWorlds or Hybrid; Default is YuiStockCompression.

Have you got any documentation on this subject or maybe can you explain in short terms what the differences are?

 

Thanks.

 

2nd Edit: I've tried all options and the output of this I've included below. The result is that using the MichaelAshsRegexEnhancements is the best option to use, even with different settings such as: Obfuscating or Preserving Semicolons.

The Options I've set are:

<CompressorTask
    CssFiles="@(CssFiles)"
    DeleteCssFiles="false"
    CssOutputFile="$(CssOutputFile)"
    CssCompressionType="/*See Below*/"
    JavaScriptFiles="@(JavaScriptFiles)"
    ObfuscateJavaScript="False"
    PreserveAllSemicolons="True"
    DisableOptimizations="Nope"
    EncodingType="Default"
    DeleteJavaScriptFiles="false"
    LineBreakPosition="-1"
    JavaScriptOutputFile="$(JavaScriptOutputFile)"
    LoggingType="ALittleBit"
    ThreadCulture="en-au"
    IsEvalIgnored="false"
    />

Result of First batch:

Compression Type: YuiStockCompression
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Stock YUI Compression
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%

Compression Type: MichaelAshsRegexEnhancements
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Micahel Ash's Regex Enhancement compression
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%

Compression Type: HaveMyCakeAndEatIt
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%

Compression Type: BestOfBothWorlds
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%

Compression Type: Hybrid
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%
  

 Setting the Obfuscate Option to True: 

<CompressorTask
    ObfuscateJavaScript="True"
/>

Result:

Compression Type: YuiStockCompression
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Stock YUI Compression
Original JS  File: 389109    Compressed : 286757 Ratio : 73.6958%

Compression Type: MichaelAshsRegexEnhancements
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Micahel Ash's Regex Enhancement compression
Original JS  File: 389109    Compressed : 307210 Ratio : 78.95217%

Compression Type: HaveMyCakeAndEatIt
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 286757 Ratio : 73.6958%

Compression Type: BestOfBothWorlds
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 286757 Ratio : 73.6958%

Compression Type: Hybrid
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 286757 Ratio : 73.6958%



Setting the Option Preserve Semicolons to False:

<CompressorTask
    PreserveAllSemicolons="False"
/>
Compression Type: YuiStockCompression
Original CSS File: 60352    Compressed : 43098    Ratio : 71.41106%
Given compression type : Stock YUI Compression
Original JS  File: 389109    Compressed : 284340 Ratio : 73.07464%

Compression Type: MichaelAshsRegexEnhancements
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Micahel Ash's Regex Enhancement compression
Original JS  File: 389109    Compressed : 284340 Ratio : 73.07464%

Compression Type: HaveMyCakeAndEatIt
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 284340 Ratio : 73.07464%

Compression Type: BestOfBothWorlds
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 284340 Ratio : 73.07464%

Compression Type: Hybrid
Original CSS File: 60352    Compressed : 42442    Ratio : 70.3241%
Given compression type : Hybrid compresssion
Original JS  File: 389109    Compressed : 284340 Ratio : 73.07464%


Coordinator
Mar 25, 2011 at 11:41 AM
Edited Mar 25, 2011 at 11:42 AM

Heya DForce.
great to hear that you've found this project AND you're giving it a go :) Personally, I don't use Michael Ash's version. I just stick to YUI stock compression .. mainly because that's tried and tested.


Now, to explain the difference decompression types :-

YuiStockCompression : This is an exact port of the original JAVA source code. The only difference (so far) is that the java code uses a hashtable for obfuscation ..  which means I can't get the exact same obfuscated characters as they do. If they decide the swap an word (eg. foo) for 'A' ... my .NET code might make that a 'D' .. but it still works identical and is the same size. Just not _exactly_ character for character identical *sigh*. I have filed a bug report and patch update on the official YUI-Compressor site ... but doubt they will get around to fixing it.

MichaelAshsRegexEnhancements : Can't remember exactly how this came about, but I think i stumbled on his code and thought I should add it in for shits and giggles. I also think it's only CSS.

HaveMyCakeAndEatIt or BestOfBothWorlds or Hybrid : any of these three options will do BOTH behind the scenes and pick the smallest result. I was just trying to be silly with the names ... but all three do the same => try YuiStock and MichaelAsh .. and return the smallest size of ehither of these two.

Default is YuiStockCompression. : if u do not provided an option, then i assume u just want YUI Stock.
does this help?

Mar 28, 2011 at 8:34 AM

Hey purekrome,

yes it clarifies things alot :) ( was already thinking that they where the same, as you used different namings for "Yes" :P )

I was just fiddling around with some of the options, but as you where stating that the best option is to use the YUI-Stock.

Just for the records: I'm developing a website with several javascripts in it and the loading time just decreased tremendously, from several seconds to 140ms!!! This is mainly because every js file is included in one file now, and even some compression added!

Thanks for your good work! I'll be looking forward to the next update!