[OpenLayers-Trac] [OpenLayers] #2900: Add Google's closure compiler to build tools

OpenLayers trac-20090302 at openlayers.org
Sun Oct 24 06:29:10 EDT 2010


#2900: Add Google's closure compiler to build tools
---------------------+------------------------------------------------------
 Reporter:  pwr      |       Owner:              
     Type:  feature  |      Status:  new         
 Priority:  minor    |   Milestone:  2.11 Release
Component:  general  |     Version:  2.10        
 Keywords:  build    |       State:  Review      
---------------------+------------------------------------------------------
 For those who don't know it, closure compiler
 http://code.google.com/closure/compiler/ compresses JS files with 3 levels
 of compression:
 - WHITESPACE_ONLY - similar to current minimize
 - SIMPLE_OPTIMIZATIONS - which shortens local variables, e.g. 'var
 meaningfulName' becomes 'var a'
 - ADVANCED_OPTIMIZATIONS - which does some more 'aggressive' compression
 to reduce the file-size further
 http://code.google.com/closure/compiler/docs/api-tutorial3.html

 I've been trying SIMPLE_OPTIMIZATIONS for a couple of months now, and find
 that it reduces build-file size by some 20% over the current minimized
 version without any loss of functionality - at least that I've noticed :-)
 I ran through the whole test suite using this optimized version and it
 produced identical results to the standard build.

 The compiler is a java program which can be downloaded and run locally,
 but it's also available as an online web service which can be accessed
 with, for example, a python script. I attach Google's sample from
 http://code.google.com/closure/compiler/docs/api-tutorial2.html modified
 to use SIMPLE_OPTIMIZATIONS. This can be run with something like:

 ./closurecompile.py <url of file to compress> > compiledBuild.js

 or you can post the actual code to be compressed.

 I would suggest that other people try out SIMPLE_OPTIMIZATIONS to check
 the functionality is unaffected, and once confirmed that this be used for
 the public api file.

 Whilst I would expect there to be no impact on SIMPLE_OPTIMIZATIONS, I
 would be less confident about ADVANCED_OPTIMIZATIONS, though it might be
 worth designing v3 with this in mind, as it would probably reduce file-
 sizes further.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/2900>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list