views:

308

answers:

2

Any website with a non-trivial amount of Javascript code is going to want to compress it for deployment. What's the best way to do this as part of the App Engine deployment process while still accessing the uncompressed javascript for easy development in the dev_appserver?

+1  A: 

One way is to write a shell script that calls the minification programs and then calls appcfg.py when it's done. I'm not sure if appcfg.py itself has any support for hooks to trigger jsmin or the YUI compressor or something.

It's not too much of a performance hit at runtime to test whether an application is deployed or not and put a link to a different javascript file if it is, but doing the actual compression at runtime is a little bit too much of a performance hit.

A shell script might look something like this:

rm root/js/js.js
cat root/js/*.js > root/js/js.js
java -jar ~/opt/yuicompressor-2.4.2.jar root/js/js.js -o root/static/js.js --line-break 4000
Brandon Thomson
+1  A: 

You may also find useful google.load() api, which deports this problem to google's servers.

Also, it's more easier to maintain and upgrade your libraries this way.

paulgreg