No, we cache it locally. We only use it to compress the javascript if
we detect that the sha1 hash of the javascript content has changed.
If the content is different, then we run it through the closure
compiler rest api, then save the contents to a file locally.
However, as a side note, I did discover something interesting. This
code causes the closure compiler to bomb, but is technically legal
javascript:
Some code had this javascript:
if (settings.class) {
anchor.attr('class', settings.class);
}
When running through closure rest api, it returns an empty string but
does not return a warning or error message. Is this a side effect of
using Java as compression here? class might be reserved in Java, but
should be legal in javascript.
Here's an example. The code below works fine for testCode1, but fails
on testCode2. The only difference between the content is that
testCode2 has "settings.class", instead of "settings.clas". The
javascript is technically valid, why would closure fail for testCode2?
require 'net/http'
testCode1 = "function test() {if (settings.clas)
{console.log('hello')}}"
testCode2 = "function test() {if (settings.class)
'js_code' => testCode2,
'compilation_level' =>
'SIMPLE_OPTIMIZATIONS',
'output_format' => 'text',
'output_info' => 'compiled_code'
})
p res.body