I've enabled the module, set it as enabled in the config, turned on js aggregation, and ran cron and cleared cache.

The JS I'm seeing is still not minified.

Thanks.

CommentFileSizeAuthor
#6 compilerjava.jpg47.56 KBManyNancy

Comments

ManyNancy’s picture

A few things, the server is sending to google http://localhost/files/7ytyg987tg8oastgt80.js

Which naturally doesn't work. I hardcoded my domain in and it starts sending. But it's sending ~200 js files, which is giving me:

Server error: Array ( [0] => Array ( [code] => 22 [error] => Too many compiles performed recently. Try again later. ) )

I think the compiler should be made part of this module, rather than as a remote thing.

mehmeta’s picture

Assigned: Unassigned » mehmeta

The standalone compiler offered by Google is based on java, so it'd require java to be installed on the server. It makes a lot of sense to offer it as an option though, so if you have java installed and the compiler.jar downloaded, the module would choose to use that instead of sending the file contents or url. I'll soon update the module whenever I have time, providing this feature.

ManyNancy’s picture

OK, Thanks!

mehmeta’s picture

Status: Active » Fixed

The latest release supports local compiling now!

Status: Fixed » Closed (fixed)

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

ManyNancy’s picture

Status: Closed (fixed) » Active
StatusFileSize
new47.56 KB

Thank you very much, I've been trying to install, but:

http://img243.imageshack.us/img243/7923/compilerjava.jpg

It might have to do with this part of your documentation:

"PHP shell_exec function to be executable in your environment without issues."

I'm not sure what that is, how do I check if that works?

Thanks.

danmasq’s picture

subscribing. I am experiencing the same issue as #6.
drupal is aggregating the javascripts, but closure compiler is not minifying/compressing the javascript at all.

danmasq’s picture

<?php
//LINE 293

/**
 * Returns whether java is installed on the machine and executable from console or not. Until someone points out a better way
 * (there's gotta be!), this is how it will happen.
 */
function closure_compiler_java_installed() {
	$output = shell_exec('java');
	return (stripos($output, 'Usage') !== FALSE);
}

so when I run this from command line, shell_exec('java') returns the 'Usage: ...' information, which is then turned into TRUE by stripos detection of the needle 'Usage'. Basically if java can't be shell_exec()'d this will return NULL, bypassing closure compiler's local compile method. aggregation will run, but the minification doesn't take place.

someone suggested that the user apache is running shell_exec() as doesn't have java in it's $PATH variable.. need to look into this still.

danmasq’s picture

ahah! my method to get it running: java 2>&1

change out:

function closure_compiler_java_installed() {
	$output = shell_exec('java');
	return (stripos($output, 'Usage') !== FALSE);
}

with:

function closure_compiler_java_installed() {
	$output = shell_exec('java 2>&1'); // the "Usage ..." message is an error stream, so we need to redirect it to the output stream
	return (stripos($output, 'Usage') !== FALSE);
}
  1. Make sure your options turned on (e.g. js aggregation, closure compiler on, local compile, simple optimizations)
  2. Delete everything in sites/default/files/js/ (might not be necessary, but just do it for kicks.)
  3. Refresh any page to regenerate your aggregated javascript
  4. Run cron.php (mysite.com/cron.php or drush queue-cron)
    • During this step, observe your js/ folder. You should see a test javascript file created, filled with data, data removed from it, then deleted. Then a new set of files should generate (hopefully deleting the old, aggregated javascript files) that will be the closure compiler... compiled javascript files.
  5. Refresh a page, view source, search for .js, click link, look for "Optimized by closure_compiler module using Google closure compiler." comment at the beginning of the file.
  6. ...
  7. profit?
johnpitcairn’s picture

Not working here I'm afraid. I've no great desire to allow java on the server, so it's set to send the file contents to the API. shell_exec is allowed.

No change after multiple cron runs - js files are aggregated, but not compressed. Log entry is "Successfully compiled 3 javascript files, 0 failed." New aggregate files are definitely being generated.

Any advice?

johnpitcairn’s picture

Scratch that. I changed nothing, but now it's working.

mattwmc’s picture

I got it working, as well!

I noticed the default process limit for js files was set to 5 for each cron run. I have 28 or so. I changed it to '0'. Not sure if that matters to others who have more than 5 and can't get it working on just a single cron run.

nburles’s picture

Status: Active » Closed (fixed)

It looks like everyone has got this working, and it has been over two years since the last comment, so I am closing this issue.