Minifier that saves conditional comments?
I tried online JS Minifier , but it strips out conditional comments like:
var u = navigator.userAgent;var e=/*@cc_on!@*/false;
BECOMES
var u=navigator.userAgent;var e=false;
This will affect how the code works, so instead of manually adding deleted comments manually, I'm looking for a minifier that intelligently stores these and any such comments.
a source to share
YUICompressor is reported to make this necessary. Here's an excerpt from the blog:
...
But don't worry, it's not as bad as you think. Unfortunately JSMin removes the comments about conditional compilation, but I believe this is because they haven't been updated for a while, rather than speeding up with modern web development techniques.
Using other tools like compressor or YUI wrapper really works great with conditional compilation. ...
You can read the entire post at http://robertnyman.com/2008/05/26/conditional-compilation-in-javascript/
a source to share
There's also a .NET YUI Compressor port that allows: -
- list merging minifiles / files into events after Visual Studio build
- go to TFS build (including CI)
- if you just want to use the DLL in your own code (for example on the fly).
because this is a port of the (original) java version of YUI Compressor mentioned above by Vinnie and Crescentfresh, it should give you the same results, but all in .NET environment - no need for java.
NTN.
a source to share