Quantcast
Viewing all articles
Browse latest Browse all 14

Yui Compressor issues with reserved words in JavaScript

For the life of me, I could not figure out why I was getting an error while running the Yui compressor on a set of my JavaScript files.

The error was very generic and not helpful

error : Failed to read in the data for the path/file [..\<path>\<filename>]. The most common cause for this is because the path is incorrect or the file name is incorrect … so please check your path and file names. Until you fix this up, I can’t continue … sowwy.

The file was present and seemed to be syntactically correct and all.

Finally, thanks to a little squiggly placed by Resharper (which is awesome!!), I found the issue. One of the js functions was called “goto” and that, apparently is reserved by JavaScript for “future use”, and Yui bombs on it.

Renaming it fixed the issue.

UPDATE

To be clear, the YUI compressor is behaving as it was designed to. Reserved words should not be used in JavaScript, as in other languages. However, I will say that the error dumped out when the compressor runs into a reserved word could be better.


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 14

Trending Articles