Sunday 22 September 2013

Javascript compressors

Another note for myself...

I have been playing with Javascript compression for frameworks, notably ENYO.

I have recently run into a couple of issues, that I need to record.

1. unexpected 0x1a character at the end of files.
This seems to be caused by the windows COPY command, and can be fixed by specifying BINARY file format in the copy, by using /b in the options.

2. Unexpected Token ILLEGAL error message from the YUICompressor based compressor.
Turns out the error reported is quite removed from the cause.
I managed to get a better error message by using the Closure compressor from google, which reported that a missing semi-colon was causing a statement to overflow to the next line.

Finally, for static javascript file compression, I have settled on a new method.
Concatenate all the needed files into a single large file using CAT, save it, and then use Closure to compress it, again from the command line. This provides easy access to both input and output, so makes debugging easier.

No comments:

Post a Comment