Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YUI Compressor and "use strict" hint

I've beeing using YUI Compressor to minify JS files. I have this code:

(function(global) {
    "use strict";

     var X=1;

    /*** my code here ***/

}(window));

And I compress it with this command:

$> java -jar yuicompressor-2.4.7.jar test.js -o test.min.js --verbose

The "use strict" hint is not present in the compressed output file. It seems that YUI removes all hints. And it output this warning:

[WARNING] Invalid hint syntax: use strict
(function(global){ ---> "use strict" <--- ;var X=1;... 

Although, my code works fine after compression, I'd like to know if there is an argument to YUICompressor to preserve the hints and/or a way to avoid that warning.

Any advice? Thanks.

like image 691
Guumaster Avatar asked Apr 23 '12 11:04

Guumaster


1 Answers

A partial explanation can be found here. Although that question is about closure compiler the answer gives you a hint (as Google also had this issue). In Closure it is possible to use --language_in=ECMASCRIPT5_STRICT

Unfortunately up to now there has been no such thing for the YUI Compressor. At least I could not find anything like that.

like image 57
Tobias Krogh Avatar answered Sep 18 '22 09:09

Tobias Krogh