Monday, July 29, 2013

JS Compilation

So you have lots of options,

  • YUI,
  • Closure,
  • UglifyJS.


Since I'm a noob at javascript minification, I've been using the default Sencha CMD yui compressor to minify my scripts. Apparently I think Sencha hacked up the compressor to be Sencha framework aware or something (so claims Sencha themselves).

When I tried using Sencha CMD to compress one of my all-classes.js scripts, it threw some js errors when I deployed.

I then tried to use Google Closure compiler online at http://closure-compiler.appspot.com/home
but it told me my file was too large. I guess I could download closure to run on my local machine, but I didn't feel like learning how to use closure at the moment.

Then I remembered earlier in the morning I crossed the site http://www.freeformatter.com/ which had a butt load of formatters and, whoop dee doo, a js compressor. They said it was also yui based, and had no effect anywhatsoever on your code.

I gave it a shot by linking my url.
Bingo!
No size limitations, no problems, and it worked during deployment. Better yet, it compressed my file just as well as the Sencha one did, so I'm not sure where Sencha went wrong.

In any case, go to http://www.freeformatter.com/javascript-minifier.html#ad-output. It's awesome!

No comments:

Post a Comment