Add support for the closure compiler webservice, using simple optimizations.

Using this build mode, on a lite build, we save approximately 15% after
gzip. However, this build method can not be used on full builds, as they
exceed the 1000kb limit on the closure compiler webservice. 


git-svn-id: http://svn.openlayers.org/trunk/openlayers@11443 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2011-02-24 22:39:40 +00:00
parent 07e34672b5
commit 8d2bbfe28f
2 changed files with 34 additions and 3 deletions

26
tools/closure_ws.py Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/python
import httplib, urllib, sys
import time
# Define the parameters for the POST request and encode them in
# a URL-safe format.
def minimize(code):
params = urllib.urlencode([
('js_code', code),
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
('output_format', 'text'),
('output_info', 'compiled_code'),
])
t = time.time()
# Always use the following value for the Content-type header.
headers = { "Content-type": "application/x-www-form-urlencoded" }
conn = httplib.HTTPConnection('closure-compiler.appspot.com')
conn.request('POST', '/compile', params, headers)
response = conn.getresponse()
data = response.read()
conn.close()
print "%.3f seconds to compile", time.time() - t
return data