>
 





Recently, I have written a C# wrapper for Google Closure Compiler to use with ASP.NET for on-the-fly JavaScript compression. For those who want to use the Closure Compiler with PHP, Bohuco.net has an article showing how to use the Google Closure Compiler over its RESTful API with PHP5.  

$script = file_get_contents('http://www.domain.com/scripts/script.js');
$ch = curl_init('http://closure-compiler.appspot.com/compile');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($script));
$output = curl_exec($ch);
curl_close($ch);

You can find more details on using Closure Compiler with PHP 5 here.

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Comments

November 9. 2009 14:43

Closure Compiler vs. YUI Compressor - Comparing the Javascript Compression Tools

Closure Compiler vs. YUI Compressor - Comparing the Javascript Compression Tools

Blogging Developer | Reply

November 10. 2009 09:55

Pingback from topsy.com

Twitter Trackbacks for
        
        Using Google Closure Compiler with PHP 5
        [bloggingdeveloper.com]
        on Topsy.com

topsy.com | Reply

November 10. 2009 10:01

Social comments and analytics for this post

This post was mentioned on Twitter by bloggingdev: Using Google Closure Compiler with PHP 5 http://su.pr/2vUIRI

uberVU - social comments | Reply

March 4. 2010 10:46

Thanks for the link

agence web | Reply

March 15. 2010 14:57

You need to be aware of what others are doing, applaud their efforts, acknowledge their successes, and encourage them in their pursuits. When we all help one another, everybody wins.

cash loans | Reply

Add comment




(Will not be displayed!)