Sep 28 2007

YUI Compressor Version 2.2.1 Now Available

Published by Julien Lecomte at 11:56 am under Web Development

I implemented a few enhancement requests and fixed a bug in this new version of the YUI Compressor. Let me know if you encounter any issue with it.

Update (9/27/07): YUI Compressor version 2.2.2 is now available. It fixes a lot of bugs that have been reported recently. By the way, I really appreciate all the bug reports, so keep them coming!

Update (9/28/07): New bugs have been reported and fixed in version 2.2.3 now available for download (check out the CHANGELOG file in the download page) And keep these bug reports coming!

Update (10/1/07): A few more minor bugs have been fixed in version 2.2.4. Thanks for the bug reports!

Download version 2.2.4 of the YUI Compressor

27 Responses to “YUI Compressor Version 2.2.1 Now Available”

  1. Alexey D. Terekhovon 26 Sep 2007 at 1:30 am

    @David Bernard

    Please add a possibility in Yuicompressor Maven Plugin to ommit suffix for compressed resource files (i.e. style.css become style.css in target direcory instead style.css). It’s very important for me to have compressed js and css files with the same name as it have initially.

    With different combination of “suffix” and “nosuffix” config parameters i can’t do what i need (b.t.w. documentation is pretty unclear for this options…).

    P.S: i write feature request for plugin (not for compressor intself) here, because i couldn’t find another way to contact with the author of that helpfull plugin.

  2. Alexey D. Terekhovon 26 Sep 2007 at 1:32 am

    Remarks for my previous comment:
    (i.e. style.css become style.css in target direcory instead style-suffix.css)

  3. […] YUI Compressor version 2.2.1 has been released. Go forth and minify! […]

  4. Papandreouon 26 Sep 2007 at 4:35 am

    Great piece of work! However, version 2.2.1 apparently introduced an error in the string literal optimizer:

    var foo = ”+’”‘;

    is incorrectly shortened to

    var foo=”"‘

    Also, conditional compilation isn’t supported everywhere (YUICompressor 2.2+). In particular, this construct throws an EvaluatorException:

    var isIE = false /*@cc_on || true @*/;

    An (even uglier) workaround for this issue:

    var isIE = eval(”false /*@cc_on || true @*/”);

    Best regards,
    Papandreou

  5. Alexey D. Terekhovon 26 Sep 2007 at 12:49 pm

    @David Bernard

    Well… All my problems with no-sufix have been solved when i completly removed net.sf.alchim.* from my local maven repo and redownload them in next build…

  6. Marcon 26 Sep 2007 at 11:00 pm

    @julien,

    (this is likely to be related to @Papandreou’s post)
    this code:
    document.write(”");

    gets transformed into:
    document.write(”");

    keep up the great work!!

  7. Marcon 26 Sep 2007 at 11:02 pm

    @julien,

    sorry, previous code got mangled upon submission

    (this is likely to be related to @Papandreou’s post)
    this string:
    “”

    gets transformed into:
    “”

    keep up the great work!!

  8. David Bernardon 27 Sep 2007 at 12:59 am

    @Maven’s users (Alexey,…)

    * to update maven’s plugin, you could remove it from your local repository or use the -U option (eg: “mvn -U package” => update of every plugin required to go to ‘package’ phase, and go to ‘package’ phase).
    * you could contact me via the sourceforge’s tracker or via the email set at http://alchim.sourceforge.net/yuicompressor-maven-plugin/team-list.html (already done by others users who ask for “nosuffix”).

    I’ll publish a new version of the plugin (upgrade to yuicompressor 2.2.1) next week-end.

  9. Rob Scotton 27 Sep 2007 at 12:00 pm

    I recently starting using YUI Compressor — great tool!

    Now to the issue :-) I’ve noticed that it barfs on files with a BOM (byte order mark). I’m guessing Visual Studio inserts the BOM; editing the files in a text editor and re-saving them fixes the problem. It would be nice if YUI would remove the BOM. Any other suggestions?

    Thanks!

  10. Julien Lecomteon 27 Sep 2007 at 12:38 pm

    Version 2.2.2 fixes all of these bugs and more.

  11. Tjerkon 27 Sep 2007 at 9:10 pm

    Version 2.2.2 (and earlier) causes problems for IE6 with the jQuery library (v1.2.1)

    The $(function(){}); construct is no longer working after compression.

  12. Julien Lecomteon 28 Sep 2007 at 9:36 am

    @Rob Scott

    There is no problem with the byte order mark. The problem here is that you are not specifying the correct character encoding (the compressor cannot guess which character encoding you used to edit the file, so you need to specify it if you did not use your platform’s default encoding) I tested this using UltraEdit, saving a JavaScript file using Unicode editing. I then gave the --charset UTF-16 option to the compressor, and it worked.

    Regards

  13. Ionel Roibanon 29 Sep 2007 at 11:31 am

    If a css file contains a comment larger than 808 characters the compressor version 2.2.3 fails.

  14. Julien Lecomteon 02 Oct 2007 at 1:21 pm

    @Ionel

    Version 2.2.4 fixed that defect.

  15. Jeses Dowellon 04 Oct 2007 at 9:26 am

    I seem to be having a problem with strings containing ‘\n’ in the source files. Seems like the compressor (post 2.1) is translating these to literal newlines in the output causing unterminated string literal problems with the generated javascript.

    Anyone else having this problem? Maybe it’s a platform issue (I’m running on Linux)?

  16. Julien Lecomteon 04 Oct 2007 at 2:08 pm

    @Jesse

    Which version are you using? I recommend you use the latest version (2.2.4)

  17. Jesse Dowellon 04 Oct 2007 at 2:27 pm

    I tried 2.2.4 and was having problems with the newline. Interestingly enough the problem doesn’t appear in version 2.1 and prior versions.

    BTW - thanks for the great tool!

  18. Julien Lecomteon 04 Oct 2007 at 2:59 pm

    @Jesse

    With version 2.2.4, the following:

    var s = “xxx\nyyy”;

    is compressed to:

    var s=”xxx\nyyy”

    I don’t see any problem with line-breaks. With version of Java are you using? Are you redirecting the standard output, or are you using the -o option?

    Thanks

  19. Jesse Dowellon 04 Oct 2007 at 4:41 pm

    Sorry, I did some further testing and discovered that it’s somehow related to my environment. I did some experimenting and found that 2.2.4 works perfectly for me if I run it from the command line ‘java -jar yuixxxxx’. If I run it as an ant task, however, this input ‘(?:)((\n|\r|.)*?)(?:)’ results in a line break in the generated file. It’s very odd that the 2.1 version does work for me from the ant script.

  20. Jesse Dowellon 04 Oct 2007 at 9:30 pm

    It was something on my classpath that was causing the problem. I changed my ant task around a bit and it works flawlessly now. Sorry about the bogus report.

  21. Stefan Kudwienon 11 Oct 2007 at 8:31 pm

    Hm, I am wondering if it this change:

    + Remove line terminator after escape in string literals.

    in the latest 2.2.5 release should be changed to inserting a escaped newline character, instead of just removing the newline. Because right now you’re changing the behavior of a script (shortening string literals - what if a script checks for a specific string length?), that’s IMO something a compressor should never do.

  22. Julien Lecomteon 12 Oct 2007 at 8:08 am

    @Stefan

    This is why the option --preserve-strings (which makes the compressor leave string literals intact) was introduced in version 2.2.3.

  23. Cezary Okupskion 13 Oct 2007 at 6:05 am

    Sorry for an informal way of submitting a feature request - is there a bug track for the compressor? I haven’t found an appropriate category on Sourceforge YUI project. Would it possible to shorten “true” to “!0″ and “false” to “!1″ (without quotes)? It works in all browsers that I’ve got, but you probably test against more.

  24. andyon 22 Oct 2007 at 1:34 pm

    @Jesse
    I’m seeing the same problem, where \r and \n are being interpreted out and giving me a line break. Any insight as to what specifically was causing this? I’m seeing this on the 2.2.4 build.

  25. Cezary Okupskion 18 Nov 2007 at 4:31 am

    WebKit (Safari 3) introduces some support for media queries. For example this works:
    @media all and (min-width:0){html{color:red}}
    while omitting the space after “and” like that:
    @media all and(min-width:0){html{color:red}}
    doesn’t.
    YUICompressor removes it. I wonder if you consider this as a bug only for the WebKit developers or something to adjust YUICompressor to.

  26. Benoit Michaudon 28 Nov 2007 at 4:09 am

    Hi,
    Would it be possible to add 1 more option? I’m thinking about some kind of automatic naming of the output.
    the standard one is: -o filename.ext
    I’d love to find: -oo filename-min.ext or anything like that.
    It would help a lot to set some automatic tasks in windows registry, or any IDE…
    Thanks anyway for your work
    Ben

  27. TomaPon 10 Jan 2008 at 3:38 am

    I am using YUIC, and it’s working fine.
    I am wondering if it could replace

    var a = new Array()
    with
    var a = []

    as suggested by JSLint

    Thanks,

    Thomas P