Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yuicompressor spits out 76 errors when minfying pdf.js #710

Closed
solsticedhiver opened this issue Oct 28, 2011 · 9 comments
Closed

yuicompressor spits out 76 errors when minfying pdf.js #710

solsticedhiver opened this issue Oct 28, 2011 · 9 comments

Comments

@solsticedhiver
Copy link

Well, I tried to minified the pdf.js with yuicompressor (2.4.6) and it fails with reporting like 76 syntax errors.

What else could I use that does not throw erros like this ?

may be you could fix pdf.js so that it please a little bit more yuicompressor ?

@jviereck
Copy link
Contributor

Working with some other compression tools, it turns out that the get foo() and set foo() syntax, that we use for some properties, can't get minified/handled by compressors.

Could this be the case here as well?

@solsticedhiver
Copy link
Author

No. It does not seem to like the variable called 'char' or 'byte' and some property named 'private'

the patch remove the "syntax errors" found by yuicompressor
https://gist.github.com/1322918

Note: the first hunk is not needed. i.e removing double vim modeline and 'use strict'
yuicompressor choke on line 13972 and I replaced all instances of private, I don't know if it's needed/correct.
Just double check before applying, please :-)

@jviereck
Copy link
Contributor

@solsticedhiver, thanks for providing this!

I'm wondering why things like 'private', 'char', 'byte' cause problems with yuicompressor. They aren't JS reserved words [1], so it should be all fine to use them.

My feeling is we shouldn't change our code due to some software, that doesn't seem to do what it should do.

@solsticedhiver, have you tried other compressors? Does they have problems as well? Is there a particular reason to use yuicompressor or is it just your flavor compressor?

[1] https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words

@solsticedhiver
Copy link
Author

about [1], private is mentionned as a reserved future keyword though
But even in that case properties.private is stil legal if I understand correctly the last paragraph on "Reserved Word usage"

yuicompressor is the one I have installed here. I was not going to use an online one with a 1MB file, was I ?

"My feeling is we shouldn't change our code due to some software, that doesn't seem to do what it should do."
Yes, I agree.
But that's not a big change either. Just some basic refactoring.

yuicompressor might have thought it's better to flag those words because they might be reserved in some implementations, From what I read http://javascript.about.com/od/reference/g/rbyte.htm I don't know what standards they talk about. but not a recent one I think...

May be one need to open a bug report against yuicompresor ??

@nateklaiber
Copy link

For what it's worth, Google Closure Compiler fails when trying to minify, and I received an exception when using YUI compressor. I haven't found anything that will work to minify pdf.js, even though it's recommended.

@sayrer
Copy link
Contributor

sayrer commented Dec 22, 2011

ES3 had a longer list of FutureReservedWords

@shenzhuxi
Copy link

I go t "Compilation produced 88 syntax errors." from yuicompressor-2.4.7.jar and commit 7859ef0

@jcheng5
Copy link

jcheng5 commented Feb 21, 2012

@nateklaiber, Google Closure Compiler actually works if you add the argument --language_in=ECMASCRIPT5 (and results in excellent compression: 737856 (min) / 1248019 (orig) = 0.591)

Novec2015 pushed a commit to Novec2015/share-extras that referenced this issue Apr 10, 2015
- Fixed build so that all files are compressed using yuicompressor, except pdf.js that needs to use jsmin due to pdf.js issue mozilla/pdf.js#710
- Moved from Alfresco namespace to ShareExtras namespace where apporiate
- Added copyright headers and js doc comments
- Moved pdf.js external library client side components to its own subdirectory
Novec2015 added a commit to Novec2015/share-extras that referenced this issue Apr 10, 2015
- Fixed build so that all files are compressed using yuicompressor, except pdf.js that needs to use jsmin due to pdf.js issue mozilla/pdf.js#710
- Moved from Alfresco namespace to ShareExtras namespace where apporiate
- Added copyright headers and js doc comments
- Moved pdf.js external library client side components to its own subdirectory
KingIsulgard pushed a commit to KingIsulgard/share-extras that referenced this issue Nov 5, 2015
- Fixed build so that all files are compressed using yuicompressor, except pdf.js that needs to use jsmin due to pdf.js issue mozilla/pdf.js#710
- Moved from Alfresco namespace to ShareExtras namespace where apporiate
- Added copyright headers and js doc comments
- Moved pdf.js external library client side components to its own subdirectory
@ExE-Boss
Copy link

The YUI compressor depends on a modified version of Mozilla’s old Rhino JavaScript runtime, which only supports ES3, and char, byte, private, and others are reserved keywords in ES3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants