We wanted to setup the Google Closure Compiler (https://www.drupal.org/project/closure_compiler) to minify the JavaScript files.

It seemed to be the easiest way to let the Closure Compiler scan through all JavaScript files and minify the missing ones, as soon as AdvAgg created new aggregations.
But the thing is, that there was no hook that was triggered after writing the files to disk.
The last hook triggered is advagg_save_aggregate_alter, right before the writing to disk starts.

The Closure Compiler has a hard processing limit of 200kb per file, larger JS content won't be accepted by the API.
Any larger files are sent to the API using their URL, so the Google server can download and process the JS content remotely.
In order to do that, the files need to be available in the file system, before sending out the request to minify them.

So I introduced a new hook: advagg_save_aggregate_post_alter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

timur_eatsmarter created an issue. See original summary.

mikeytown2’s picture

Have you tried the AdvAgg External Compression module? Has support for Google Closure Compiler via local or remote (via curl).

mikeytown2’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: advagg-post_save_hook-2826075-1.patch, failed testing.

The last submitted patch, 2: advagg-post_save_hook-2826075-1.patch, failed testing.

The last submitted patch, 2: advagg-post_save_hook-2826075-1.patch, failed testing.

mikeytown2’s picture

Version: 7.x-2.18 » 7.x-1.x-dev
Status: Needs work » Needs review
mikeytown2’s picture

Status: Needs review » Postponed (maintainer needs more info)

Patch doesn't apply and I need to know if the AdvAgg External Compression submodule does what you need it to do.

timur_eatsmarter’s picture

timur_eatsmarter’s picture

I'm afraid the External Compression submodule can't supply any JS files to the Online Google Closure Compiler.
I used the example given on the config page (curl -o {%OUT%} -d output_info=compiled_code -d code_url={%IN_URL_ENC%} http://closure-compiler.appspot.com/compile), but nothing seems to happen.
After adding some watchdog messages to advagg_ext_compress_js_compress() and advagg_ext_compress_execute_cmd() I found out, that Google has no access to the temporary JS files (e.g. sites/default/files/advagg_file_qj7Czq.js).
The files are created having the permission -rw------- and thus can't be delivered by Apache.

mikeytown2’s picture

Ok that shouldn't be too hard to fix. I'll get you a patch later on today

mikeytown2’s picture

Status: Postponed (maintainer needs more info) » Needs review

Testing the patch you submitted

mikeytown2’s picture

Here's the fix for temp file permissions and better logging of errors.

mikeytown2’s picture

  • mikeytown2 committed 4980235 on 7.x-2.x
    Issue #2826075 by mikeytown2: Better debug output from external...

  • mikeytown2 committed c26899a on 7.x-2.x
    Issue #2826075 by mikeytown2: Better debug output from external...
mikeytown2’s picture

Status: Needs review » Active

This patch is in the latest dev now.

timur_eatsmarter’s picture

Thanks for the patch.
I tested the External Compression submodule thoroughly, but I was not able to get the Closure Compiler to work.
Worked fine on my local dev environment, but on sandbox nothing happened, not even a single error message.
Since I ran out of time for now, we will stick to the post_save_hook patch for the time being, and will give the External Compression submodule a chance sometime later.

Maybe there is anybody else that can test the combination of External Compression, Command Line and Google Closure Compiler?

mikeytown2’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

Any word on where this is for you?

mikeytown2’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.