Results 1 to 7 of 7

Thread: Yui Compressor, Obfuscation Errors

  1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    98
    Vote Rating
    0
      0  

    Default Yui Compressor, Obfuscation Errors

    I've been trying to find an obfuscator for my JS files and am having some trouble with the ones I've tested. Specifically with Yuicompressor I receive syntax errors during obfuscation:
    Code:
    ... yuicompressor-2.3.4.jar"  "C:\obf tests\Copy of testpreobf1.js"
    
    [ERROR] 1:2:illegal character
    
    [ERROR] 1:2:syntax error
    
    [ERROR] 1:3:illegal character
    
    [ERROR] 1:0:Compilation produced 3 syntax errors.
    org.mozilla.javascript.EvaluatorException: Compilation produced 3 syntax errors.
    
            at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICom
    pressor.java:143)
            at org.mozilla.javascript.Parser.parse(Parser.java:402)
            at org.mozilla.javascript.Parser.parse(Parser.java:347)
            at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScri
    ptCompressor.java:312)
            at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScr
    iptCompressor.java:532)
            at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.ja
    va:120)
    Can anything be derived from this error message? I have no clue as to what it's complaining about.

    I ran the same JS code through JSLint and the only errors I received were nothing more than warnings such as line breaks and missing '{' for one-line if-statements.

    Can anyone suggest a similar (perhaps free?) obfuscator/minifier that is a bit more flexible or at least a bit more detailed in its errors?

  2. #2
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
      0  

    Default

    woah... YUICompressor's the best one i know of...

    i've never seen those errors before btw.

    try removing those spaces from your js file's filename for starters.

    p.s. version 2.3.5 is already out. couple of bugfixes made it into this version.
    p.s.s. if you could post a little snippet of that file i could run it through my yuicompressor and see what it turns up.

  3. #3
    Ext User
    Join Date
    Oct 2007
    Posts
    98
    Vote Rating
    0
      0  

    Default

    I'm in a bit of disbelief. Found something called Javascript-Obfuscator from javascript-source and it worked flawlessly (has a price tag, but that's ok..). I wonder why J-O has no issues but YUI Compressor freaks out? I put the obfuscated code into my project and it runs perfectly. Went from 36k to 22k and that was at the default obfuscation settings (no variable name changes).

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,891
    Vote Rating
    89
      0  

    Default

    Don't post here about it, tell the author!

    http://www.julienlecomte.net/blog/

  5. #5
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
      0  

    Default

    if i may be allowed one last post

    @ferr, yuicompressor isn't exactly an obfuscator per se, but it sure as heck does a fantastic job of compressing code and checking for errors. be sure to drop a bug report @ the YUI sourceforge site for yuicompressor. i filed one bug and the author had it fixed within the week.

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Moscow
    Posts
    29
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by ferr View Post
    [ERROR] 1:2:illegal character

    [ERROR] 1:2yntax error

    [ERROR] 1:3:illegal character

    [ERROR] 1:0:Compilation produced 3 syntax errors.
    I had same issues on < 2.3 revisions of yui-compressor. It was encoding issue in my case.
    Try to add "--charset utf-8" or replace utf-8 with appropriate encoding.

  7. #7
    Ext User
    Join Date
    Oct 2007
    Posts
    98
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by CPliskin View Post
    I had same issues on < 2.3 revisions of yui-compressor. It was encoding issue in my case.
    Try to add "--charset utf-8" or replace utf-8 with appropriate encoding.
    That option worked for me. And YUI-C gave me an increase in reduction versus J-O by about 15% thanks to the automatic local variable renaming.. and it's free! thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •