yui / yuicompressor Goto Github PK
View Code? Open in Web Editor NEWYUI Compressor
Home Page: http://yui.github.com/yuicompressor/
License: Other
YUI Compressor
Home Page: http://yui.github.com/yuicompressor/
License: Other
hello,
command like yuicompressor -o c:\temp\sample.js c:\dev\sample.js not work anymore in 2.4.8 (invalid filename) :(
Error js compress when hash object has name property as type data.
Example:
hash = {
int: true
}
funny, but even on the types of data that are not in javascript
hash = {
long: true
}
http://www.yuiblog.com/blog/2013/05/16/yuicompressor-2-4-8-released/
Just getting Error establishing a database connection
The following discussion explains what command line variables to use to speed up compilation, especially under 64bit machines.
The same can help yuicompressor
https://groups.google.com/forum/?fromgroups=#!topic/closure-library-discuss/7w_O9-vzlj4
I have run across this error that was rgb(280, 155, 55) ans the converted hex was respectively too large. A check for correct rgb color values before converting them to hex would be useful.
Best I can tell is that YUI compressor 2.4.8 is breaking hsl color values by removing the % in the S and L entries. Testing with:
.SB-messages .SB-message a {
color: rgb(185, 99, 117);
border-bottom: 1px dotted rgb(185, 99, 117;
text-shadow: 0 1px 0 hsla(0, 0%, 0%, 1);
}
Produces:
.SB-messages .SB-message a{color:#b96375;border-bottom:1px dotted rgb(185,99,117;text-shadow:0 1px 0 hsla(0,0,0,1)}
Which does not work in chrome for me.
If your code is like
var foo = {
delete : "asd"
};
then the compressor will give syntax errors, while the code is perfectly correct as per ES5, but is incorrect as per ES3.
Are there any plans to support ES5, or if you already are supporting ES5, then consider this as a new bug.
The last version available to Maven is v2.4.7.
For security reasons, there might be scenario's in which you would like to remove all comments of a file, including the so called important comments.
Since a couple of versions back (somewhere in 2009), the default behavior was changed to not include these important comments when removing all comments.
It would be good to have an option to remove these comments anyway.
E.g. --remove-all-comments
E.g.
/! This comment will not be removed, but it includes a version number that attackers might be interested in on production servers */
// this comment will be removed
/ this one too */
hello
i want to create a application for compress js and lesscss and have problems with this library.
lesscss component used rhiono for compile lesscss
and your rhino library have some changes that lesscss library could not use this
you can give me any solution?
If !important
is used on css declarations, the whitespace before it is stripped, rendering the whole important and the declaration obsolete.
I recently had a problem with a website built on Twitter Bootstrap. I was using the .visible-desktop, .hidden-phone, etc responsive classes, and they just wouldn't work. The .visible-desktop, would not appear on a desktop! When I used the uncompressed versions of the CSS files everything worked ok, and it was only when I compressed and minified them that the problems started.
The solution was relatively easy, once I'd figured out why. I was using YUI Compressor to minimize and combine the various CSS files into one.
The combining was not an issue, but the media queries were getting changed from:
Before
@media only screen and (-webkit-min-device-pixel-ratio: 1.5)
After
@media only screen and(-webkit-min-device-pixel-ratio: 1.5){}
Fix
@media (min-width: 768px) and /*!YUI-Compressor */ (max-width: 979px)
I have simple javascript like:
var foo = function() {
this._id = 'id';
}
foo.prototype = {
get id()
{
return this._id;
},
set id(id)
{
this._id = id;
}
}
The yuicompressor output is:
var foo=function(){this._id="id"};foo.prototype={get idfunction(){return this._id
},set idfunction(id){this._id=id}};
ISSUE:
'id' is translated into 'idfunction', which leads to 'id' can not be get and set correctly.
Someone has added an extension that i think would would be nice to have added to main. The main use of this is to strip debug statements, but it is generic and could be used for other things. See http://brooknovak.wordpress.com/software-projects/yui-compressor-ext/#downloads
Not a CSS guru, but found this error when compressing bootstrap 3.0:
Input:
@media screen and (min-width: 768px) {
...
}
Output:
@media screen and(min-width: 768px) {...}
Notice the space missing between 'and' and '(', this causes an error with chrome.
Love this tool btw!
Regards
The Javascript file ibox.js from http://www.enthropia.com/labs/ibox/ produces 97 syntax errors. Though with the v2.4.7 of yuicompressor the file compiled without errors.
Trying to pass my javascript path to YUI compressor. If I $ cd ~/Desktop
, why is it that this will work:
$ yuicompressor -v -o '$:.min.js' ~/Desktop/js/*.js
but this will not:
$ yuicompressor -v -o '~/Desktop/js/$:.min.js' ~/Desktop/js/*.js
Thanks.
In this page http://yui.github.io/yuicompressor/ the download link points to here http://yuilibrary.com/download/#yuicompressor which is no longer the download location for yuicompressor.
[ERROR] 13:3:syntax error
[ERROR] 3692:3:syntax error
[ERROR] 5545:2:syntax error
[ERROR] 9597:2:syntax error
[ERROR] 1:0:Compilation produced 4 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 4 syntax errors.
at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:161)
at org.mozilla.javascript.Parser.parse(Parser.java:396)
at org.mozilla.javascript.Parser.parse(Parser.java:340)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:536)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Can't seem to find out why.
Strict mode is one of the most valuable features in ECMAScript 5.
Unfortunately YUI compressor removes the "use strict"; directive.
In the current version, trying to compress a file with c-style comments with exclamation marks such as:
/*!
* test
*/
will produce syntax errors corresponding to the end of the comment:
[ERROR] 3:2:syntax error
when I build and use it via command line java -jar yuicompressor-2.4.8pre.jar -o test.min.js test.js
$ echo "0x0.toString()" > test.js
$ java -jar yuicompressor-2.4.8.jar test.js
0.toString();
0.toString();
is not the correct syntax here, it should be (0).toString();
or possibly 0..toString();
Any way to get yuicompressor to condense CSS?
When using that we need to override but don't want to edit - eg twitter bootstrap. We will create our own stylesheet that overrides the base, but when the files are merged together the resulting file has unnecessary rules for example:
source.css
.alert {
padding: 8px 35px 8px 14px;
margin-bottom: 5px;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
background-color: #cccccc;
border: 1px solid #ff0000;
color: #ff0000;
}
our.css
.alert {
margin-bottom: 8px;
background-color: #f5f5f5;
border: 2px solid #000000;
z-index: 5;
}
actual-result.css
.alert {
padding: 8px 35px 8px 14px;
margin-bottom: 5px;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
background-color: #cccccc;
border: 1px solid #ff0000;
color: #ff0000;
}
.alert {
margin-bottom: 8px;
background-color: #f5f5f5;
border: 2px solid #000000;
z-index: 5;
}
preferred-result.css
.alert {
padding: 8px 35px 8px 14px;
margin-bottom: 8px;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
background-color: #f5f5f5;
border: 2px solid #000000;
color: #ff0000;
z-index: 5;
}
Fails with "missing ; before statement" on line:
var stIsIE = /@cc_on!@/false;
I have the following piece of code that YUICompressor doesn't like:
var listitem = $("<li>").
append($("<a>",
{
href: "#",
class: "searchanchor",
id: result.Id, onclick: "search_navigate('" + result.Url + "');",
text: result.Title })).
append($("<p>", { class: "searchdescription", text: result.Description }));
The compressor doesn't like the "class:" stuff. But this code functions properly for me, so I'm guessing YUICompressor is at fault. I'm not a javascript pro, so I could be wrong.
The piece of js code is as follows:
.....
a.findAndModify(
{a: a},
[],
{$set: {a: a, b: b, updated_at: new Date()}},
{ new: true, upsert: true }, // line 173
function(err, doc) {
if(err) {
util.logError(logger, "error!", err);
return;
}
}
);
}
.....
got errors when doing compress:
[ERROR] 173:12:invalid property id
[ERROR] 174:26:missing ; before statement
[ERROR] 175:16:missing ; before statement
[ERROR] 176:14:syntax error
[ERROR] 183:5:'try' without 'catch' or 'finally'
[ERROR] 184:9:unlabelled break must be inside loop or switch
[ERROR] 185:7:syntax error
[ERROR] 186:9:missing ; before statement
[ERROR] 209:9:unlabelled break must be inside loop or switch
[ERROR] 211:2:syntax error
[ERROR] 212:8:syntax error
[ERROR] 213:2:syntax error
[ERROR] 1:0:Compilation produced 12 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 12 syntax errors.
at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:154)
at org.mozilla.javascript.Parser.parse(Parser.java:392)
at org.mozilla.javascript.Parser.parse(Parser.java:337)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:533)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Please help estimate whether it's a program bug or a wrong usage.
Thanks
Considering following code:
.diamond {
filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865475, M12=-0.7071067811865477, M21=0.7071067811865477, M22=0.7071067811865475, SizingMethod='auto expand');
}
The compressed result:
.diamond{filter:progid:DXImageTransform.Microsoft.Matrix(M11=0.7071067811865475,M12=-0.7071067811865477,M21=0.7071067811865477,M22=0.7071067811865475,SizingMethod='auto expand');}
This will not work in ie6, ie7 or other ie related browsers. Here's an article about this problem: https://clientsize.wordpress.com/2011/06/15/dximagetransform-microsoft-matrix-and-the-great-minify-mystery/
If we try to compress a javascript with only a "\n" character, it produces an Exception.
I founded the issue source.
In JavaScriptCompressor.java , in
private StringBuffer printSymbolTree(int linebreakpos, boolean preserveAllSemiColons) function, it has a:
JavaScriptToken lastToken = getToken(0);
But it does not care if "tokens.size()==0".. so when it tries to retrieve the token, it produces the Exception.
I changed in my version to:
JavaScriptToken lastToken = null;
int length = tokens.size();
if(tokens.size()>0)
lastToken = getToken(0);
I proved and it seems to work.
.issue-59 {
width:100%;
width: -webkit-calc(100% + 30px);
width: -moz-calc(100% + 30px);
width: calc(100% + 30px);
}
turns into
.issue-59{width:100%;width:-webkit-calc(100%+30px);width:-moz-calc(100%+30px);width:calc(100%+30px)}
instead of
.issue-59{width:100%;width:-webkit-calc(100% + 30px);width:-moz-calc(100% + 30px);width:calc(100% + 30px)}
Notice the missing spaces
Hi,
It seems that yui Compressor "minimize" text-shadow: 0 0; to text-shadow:0; but this syntax does not seem "correct" according to w3c specification.
Is there any way to avoid this ?
Regards
I noticed some applications were hanging when relying on yuicompressor
to finish executing on stdin input.
After tinkering, I discovered that I can't actually end the stdin from a terminal either:
$ yuicompressor --type css
.blahblah {
display: block;
}
^D
I push Ctrl-D to signal EOF and nothing happens. I push enter a few times, input Ctrl-D a few more times. Nothing.
This stands in contrast to using other utilities such as ugilfyjs
, or any host of other unix command line tools (e.g., cat
).
Any ideas? What special treatment do I need to give the input stream to let yuicompressor
return properly?
I need to mangle all members prefixed with a single underscore, Is it possible?
Seeing this is a java project can a maven archetype be added to this project build for easy importing into java based builds?
REF
http://maven.apache.org/archetype/maven-archetype-plugin/advanced-usage.html
I optimized the “Harmony Collections Shim” (https://github.com/Benvie/harmony-collections/blob/master/harmony-collections.js). Safari on Mac OS X and iOS fails to parse the resulting file with “SyntaxError: At least one digit must occur after a decimal point”.
Source code from harmony-collections.js causing the error when optimized:
$ echo '.0.toString()' | bin/yuicompressor --type js --charset utf-8
0.toString();
Safari debug console:
> 0.toString()
SyntaxError: At least one digit must occur after a decimal point
Workaround:
$ echo '(.0).toString()' | bin/yuicompressor --type js --charset utf-8
(0).toString();
Workaround in debug console:
> (0).toString()
"0"
Seems we have to fix something in YuiCompressor, so we can compress pdf.js mozilla/pdf.js#2479
In 2.4.7, it was possible to specify an absolute path for the output file. Attempting to do this in 2.4.8 causes the following error:
java -jar "C:\Path\To\yuicompressor-2.4.8.jar" --charset UTF-8 --type js -o "C:\outputfile.min.js" "C:\path\to\source\file.js"
java.io.FileNotFoundException: outputfile.min.js:\path\to\source\file.js (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
According to the ECMAScript Language Specification, 5th ed., section 14.1 "Directive Prologues and the Use Strict Directive" the directive prologue may consist of an arbitrary number of lines. This suggests that hints should be recognized on any line of the prologue.
Example:
function foo() {
"use strict";
"longBlah:nomunge";
var
longBlah = "long blah",
longBlub = "long blub";
return longBlah + " and " + longBlub;
}
->
function foo(){"longBlah:nomunge";var a="long blah",b="long blub";return a+" and "+b};
while
function foo() {
"longBlah:nomunge";
"use strict";
var
longBlah = "long blah",
longBlub = "long blub";
return longBlah + " and " + longBlub;
}
->
function foo(){"use strict";var longBlah="long blah",a="long blub";return longBlah+" and "+a};
See also issue #71.
[ERROR] 4051:32:missing name after . operator
[ERROR] 4090:35:missing name after . operator
[ERROR] 4092:30:Invalid assignment left-hand side.
[ERROR] 4100:12:missing ) after argument list
[ERROR] 4101:8:syntax error
[ERROR] 4102:8:syntax error
[ERROR] 4103:94:missing ; before statement
[ERROR] 4113:4:missing ) in parenthetical
[ERROR] 4114:3:syntax error
[ERROR] 4115:3:syntax error
[ERROR] 4117:10:syntax error
[ERROR] 4118:9:syntax error
[ERROR] 4119:11:syntax error
[ERROR] 4120:3:syntax error
[ERROR] 4122:7:syntax error
[ERROR] 4128:10:invalid return
[ERROR] 4140:10:invalid return
[ERROR] 4145:10:invalid return
[ERROR] 4149:2:syntax error
[ERROR] 4151:12:syntax error
[ERROR] 4152:12:syntax error
[ERROR] 4153:8:syntax error
[ERROR] 4157:4:syntax error
[ERROR] 4159:2:syntax error
[ERROR] 4160:2:syntax error
[ERROR] 4174:39:missing name after . operator
[ERROR] 4174:56:illegal character
[ERROR] 4174:84:unterminated regular expression literal
[ERROR] 4194:1:syntax error
[ERROR] 8755:1:syntax error
[ERROR] 1:0:Compilation produced 30 syntax errors.
Hello,
i don't have any java compiler, is it possible to put the yuicompressor.jar file inside the master download ? or at least a link to the last version available for download ?
For CSS, given a rule such as:
input {
font-size:1.0em;
}
From what I can tell the optimizer replaces 1.0em with 1.0. This is not valid, it should stay 1em.
Trying to do anything after updating gives me the following error:
Jonathans-MacBook-Pro:funraiseme jonathanong$ yuicompressor -v
fs.js:654
return binding.readdir(pathModule._makeLong(path));
^
Error: ENOENT, no such file or directory '/usr/local/lib/node_modules/yuicompressor/build'
at Object.fs.readdirSync (fs.js:654:18)
at Object.<anonymous> (/usr/local/lib/node_modules/yuicompressor/nodejs/index.js:7:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/local/lib/node_modules/yuicompressor/nodejs/cli.js:10:18)
at Module._compile (module.js:456:26)
Mac OS X 10.8.3
downgrading to 2.4.7 works
identifier is a reserved word. Source: null, Line: 3,420, Pos: 29, Text: debugger;
try {
...
debugger;
...
}
at org.mozilla.javascript.Parser.addError(Parser.java:122)
at org.mozilla.javascript.Parser.reportError(Parser.java:136)
at org.mozilla.javascript.Parser.primaryExpr(Parser.java:2110)
at org.mozilla.javascript.Parser.memberExpr(Parser.java:1730)
at org.mozilla.javascript.Parser.unaryExpr(Parser.java:1591)
at org.mozilla.javascript.Parser.mulExpr(Parser.java:1520)
at org.mozilla.javascript.Parser.addExpr(Parser.java:1501)
at org.mozilla.javascript.Parser.shiftExpr(Parser.java:1481)
at org.mozilla.javascript.Parser.relExpr(Parser.java:1455)
at org.mozilla.javascript.Parser.eqExpr(Parser.java:1411)
at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:1400)
at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:1389)
at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:1378)
at org.mozilla.javascript.Parser.andExpr(Parser.java:1366)
at org.mozilla.javascript.Parser.orExpr(Parser.java:1354)
at org.mozilla.javascript.Parser.condExpr(Parser.java:1337)
at org.mozilla.javascript.Parser.assignExpr(Parser.java:1322)
at org.mozilla.javascript.Parser.expr(Parser.java:1309)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:1206)
at org.mozilla.javascript.Parser.statement(Parser.java:656)
at org.mozilla.javascript.Parser.statements(Parser.java:604)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:1108)
at org.mozilla.javascript.Parser.statement(Parser.java:656)
at org.mozilla.javascript.Parser.statementHelper(Parser.java:702)
at org.mozilla.javascript.Parser.statement(Parser.java:656)
at org.mozilla.javascript.Parser.parseFunctionBody(Parser.java:440)
at org.mozilla.javascript.Parser.function(Parser.java:547)
yuicompressor/src/com/yahoo/platform/yui/compressor/CssCompressor.java
Lines 328 to 333 in c60c6ff
These lines lead to the following change in code:
-webkit-transform-origin: 0px 0px;
into:
-webkit-transform-origin: 0;
which does something very different than one might expect. In this case the default y origin transform is 50%, so the text will be unexpectedly offset by 50% the height of the element.
Thanks for all your hard work on this utility.
The fraction used in a Opera device pixel ratio query will cause an issue. The following example:
@media print,
(-o-min-device-pixel-ratio: 5/4),
(-webkit-min-device-pixel-ratio: 1.25),
(min-resolution: 120dpi) {
/* Style adjustments for high resolution devices */
}
@media print {
* {
background: transparent !important;
color: #000 !important; /* Black prints faster: h5bp.com/s */
box-shadow: none !important;
text-shadow: none !important;
}
}
becomes:
@media print,(-o-min-device-pixel-ratio:5/@media print{*{background:transparent!important;color:#000!important;box-shadow:none!important;text-shadow:none!important}}
Using a decimal instead of a fraction fixes but Opera requires a fraction. I tested with version 2.4.7 and 2.4.8pre as part of ant-build-script.
Taking the following CSS:
@keyframe anim {
0% { opacity: 0; }
100% { opacity: 1; }
}
The output will be incorrectly rewritten to:
@keyframe anim {
0 { opacity: 0; }
100% { opacity: 1; }
}
This is not functionally equivalent.
index.js line 38
options.type = ext;
should be
options.type = options.type || ext;
to compatible with special ext
Fails to compress the angularjs source that has a function similar to this:
function int(str) { return parseInt(str, 10); }
Fails with error: identifier is a reserved word.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.