Module: Tipsy::Compressors::Closure
- Defined in:
- lib/tipsy/compressors/javascript_compressor.rb
Instance Method Summary collapse
Instance Method Details
#compress(js) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tipsy/compressors/javascript_compressor.rb', line 13 def compress(js) return js unless Tipsy::Site.config.compile.compress_javascripts return js if js.to_s.blank? post_data = { 'compilation_level' => 'SIMPLE_OPTIMIZATIONS', 'js_code' => js.to_s, 'output_format' => 'text' } request = Net::HTTP.post_form(URI.parse('http://closure-compiler.appspot.com/compile'), post_data) request.body.to_s end |