I have a php application that accepts the presented javascript code and uses the Google Closure compiler to minimize it.
The php script uses the exec () command to call the compiler as follows:
exec('java -jar compiler.jar --js file.js', $output);
The problem with this approach is the time it takes for the java engine to load the .jar compiler each time and perform the compression, about 3 seconds, to minimize simple code:
alert ( "hello" );
I assume this is due to the time it takes to load the java engine and jar file, as well as the time required to process the javascript code.
My question is, which options improve speed here?
One of the ideas that I like is perhaps turning compiler.jar into a servlet that receives a message with code and parameters, then returns the result via http or socket and runs it in Tomcat. But since I'm not familiar with Java code, this approach can be tricky, and yet I don't know if this will significantly improve speed.
Please let me know how you would approach him, thanks!
Tamas source share