angular/angular.js — pull request #597 by IgorMinar (2011-10-15 23:48:28+00:00)
Title: Closure Compiler Advanced Optimization Pretotype

THIS IS JUST A PRETOTYPE!

I had an idea last night and it appears to work!

# Main points

- write angular app app (make sure you export it into window namespace so that the compiler doesn't throw it all away as dead code)
- compile with closure compiler in advanced mode (see command below)
- change html file to reference the minified version of the js file
- grap personalLog.min_props_map.out and turn it into a comma separated string
- put the string into symbols.js (this is a pretotype hack)
- load symbols.js as a js script
- load the app in the browser
- since I modified the parser and injector to consult the `symbol` function when looking up any symbols, all lookups work properly and all minified symbols get properly resolved!

# Issues

Since you have to include the symbols maps with your app so that angular can maps symbols correctly, there are two issues with this approach:

- the size of the minified app is slightly bigger that when the symbols map is not included (for large apps this should be insignificant)
- it's easy to de-obfuscate the code and read it (the symbols can be seen in the templates so this is no worse than simple optimization

In order to make this work properly, we'll also need to export all of the angular api's or create an externs file.

# Size comparison

simple vs advanced optimizations: 414 bytes vs 435 (348+87) bytes

# Conclusion

We do want full advanced optimization with template rewriting, but until we get there, this is could be a valuable feature with many of the same benefits and few drawbacks. Best of all, it is significantly easier to implement.

# Misc

compiler command used:

```
java -jar ../../lib/closure-compiler/compiler.jar \
--compilation_level ADVANCED_OPTIMIZATIONS \
--js personalLog.js
--js_output_file ./personalLog.min.js \
--create_name_map_files
```