CompressionType = None?

Jan 17, 2012 at 5:21 PM

This is good feature no?

Jan 17, 2012 at 10:51 PM

Agreed. In Debug mode I may want to combine the file, but not compress it

Jan 17, 2012 at 11:49 PM

So, are you guys saying that when this is set to NONE, then it is still compressing?

Jan 18, 2012 at 10:51 AM
Edited Jan 18, 2012 at 10:53 AM

CompressionType = None, if I understand the suggestion correctly, would simply concatenate the files.

I'm not sure it's worth to be there as a feature. First of all, there's already an option to skip obfuscation - you can use that to retain the variable names. You can then use Chrome Developer Tools and "beautify" your JS. However that (and no compression) would still be a problem, because you'd need to trace the correct file to debug. This is why I'd suggest the following flow:

1. Compress files fully, but retain original versions

2. Have a config param which lets you decide which files to use - original ones or the compressed one

3. On production (and staging/QA), you would use compressed files by default, and on development boxes you would use original files - with an option to skip to the compressed on. You should also deploy both versions (compressed and raw) into production, so that you can switch that with config, in case you have a problem you need to debug in production.

This way you actually also save a lot of time, because you don't have to rebuild to be able to debug JS - which is even further helpful if you keep your JS/CSS/images in a different solution for static files - which you should, and you also should deploy them on a separate vhost/CDN for performance.

Either way, it's really simple to do easy concatenation with msbuild - so maybe instead of using YuiCompressor you should have an alternate which simply concatenates the files into one?

Jan 18, 2012 at 3:22 PM

purekrome: It looks like there is no parameter available to specify that I want my JavaScript files combined and not minified.

dominkyas: Yes, we are lobbying for a CompressionType=None of Minify = False that will combine the Javascript files. This along with setting ObfuscateJavaScript to false would lead to one file that combines the js files, but does nothing else to them. All variables names remain untouched and all comments stay in place. I like the idea of being able to switch in production, and will look into it further, but I say that doesn't negate the need for CompressionType=None or Minify = False...

Let me give you an example of why I would use this feature. I have a ASP .NET AJAX server control that contains a large number of javascript files. I have thousands of lines of code in these files and I like having multiple files because it is easier for me to develop. When the control is placed on the page, I have the control ask for these files (it outputs <script> tags via the ScriptManager on the page). In Release mode, I have it ask for the 1 combined, minified and obfuscated JavaScript file. In Debug mode I currently have it requesting all of the files. Fore each Javascript file, I therefore, have to set the file as an embedded resource, have to add a reference in my AssemblyInfo.vb file and need to add a line in my server control to add this file to what is output to the page (as a <script> tag). What I would love to do is on Debug mode, as a pre-build option, have the javascript files combined into 1, but not minified or obfuscated. That way I can debug, but I don't have to bother about setting each individual file as an embedded resource, adding a reference in AssemblyInfo.vb, and adding a line in my server control to output the script tag for that file. So I can just keep adding javascript files without having to do those extra steps.

I think it's as easy as one line in the CompressorTask.Compress method, to combine files but not minify them. So I don't think it would be that much effort, but bring some benefits.

Jan 27, 2012 at 8:01 AM

It's not rocket science to concatenate files, so there's no real need to add this to YUICompressor.....BUT I guess you could see this as the equivalent of a compression level of "Store" in a zip file, so from that point of view, perhaps we could add it..... purekrome?

Jan 27, 2012 at 11:29 AM


My first gut instinct is that I don't really like the idea. 

Like freeranger suggested, it's easy to concat/join/combine files together. Secondly, this is a Js/Css -compression- library,

Now i understand the requirement that in dev mode, not to compress and minify, etc. And I agree that, that's a proper way to do development. I more or less do that to.

But I think it's a bit .. donno .. weird.

Especially if you can achieve this -easily- using MSBuild already :P

Jan 27, 2012 at 11:45 AM

I find the idea of a zip file that is not compressed a bit weird myself, and indeed we don't *have* to do something just because PkZip and friends do it...but this would be trivial to add, so I would be happy to do it if it helps some people out...but it's your library PK, so your shout :)

Jan 27, 2012 at 11:50 AM

If we can leave it out, can we provide some same (msbuild) documentation that shows how to leverage that to join files, instead of using YUICompressor (if it could do it)?

maybe that would be a nice compromise so people who are using/thinking of using YUICompressor.NET .. are thinking "hmm.. what about no compression/mini and just combining .... AH! i can actually do this already with msbuild .. and there's the answer .. awesome. I can now have my cake AND eat it :P"

suitable compromise?

Jan 27, 2012 at 12:02 PM

Here is a way to do it:

Though it strips out tabs and blank lines, so it's not quite the same as a "store"

Jan 27, 2012 at 12:09 PM

I was thinking about using the <Exec ... > command.

We should ask how to do it on StackOverflow. Not how to use the MSBuild exec command .. but a command line thingy that can concat AND handles international files.

I usually use the copy /b command (i think it was /b for binary) .. so i'm not sure about text files or utf16 etc...

StackOverflow will help us, here.

(I'm camping with the family, so i'll do that in a few days, if u don't get a chance to before then. We'll post the SO link in here as a reference).

Jan 27, 2012 at 12:31 PM

Sounds like more effort than just adding the CompressionType = None option :)

Jan 27, 2012 at 12:50 PM

K. then lets add in a None option. Easiest path, IMO :)

Jan 27, 2012 at 3:38 PM

lol :)

Jan 27, 2012 at 3:40 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jan 28, 2012 at 1:37 PM

Checked in as part of change set  74419