Minified Code Producing Error - Solved

Posted on
  • I was getting errors in some minified code (simple minification) and have identified the issue:

    My function had two return statements - one within a loop, the other at the end of the function (sloppy , I know!!).

    This caused the minifier to output a labelled break which isn't supported by Espruino.

    Refactoring the function to have only one return statement solved the issue - hopefully this is of help to someone else.

    (edit: Probably should have been posted this in the Javascript forum)

  • Great - glad you got it sorted.

    Thanks for letting me know - I had no idea the closure compiler did that - it could be a recent addition. Maybe it adds a bit more urgency to the label implementation :)

    Either that or I should get the offline minifier done.

  • It really surprised me - I thought simple minification only removed comments/white space & renamed local variables/function names.

    I don't mind the lack of support for labels - I don't tend to use them anyway, too much like goto.

  • Really weird things happen when throwing minification and Espruino together - see http://forum.espruino.com/conversations/­256957/ - where all of a sudden the if does not work anymore... nor the try-catch... and only the addition of some application-useless but minification-tricking (noise) code get's the things back to work again.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Minified Code Producing Error - Solved

Posted by Avatar for DaveNI @DaveNI

Actions