ecentinela / compiler

PHP/CLI: Automatic compiles all your javascript in the cloud with Google Closure Compiler

This URL has Read+Write access

ecentinela (author)
Mon Nov 09 03:17:16 -0800 2009
commit  7ec57bb7b48fb7e7afdf4d3039772f3f8bf5a3bf
tree    cbb82109d453f76c9799c8f855a9383f931047da
parent  31ce59a58405e39254fb6703f2a290b7cc74b7dd
name age message
file README.md Loading commit data...
file compile.php
file compiler.php
README.md

Problem

  • Javascript files are too large because they are not optimized
  • Users & your bandwidth is wasted for useless data
  • local javascript optimization requires tons of programs / libaries / knowledge

Solution

  • Google Closure Compiler size reduction (10-97% size reduction) in the cloud
  • optmizes all javascript files from a given folder

Usage

Compiles a single javascript file or a whole folder in the cloud.

Usage:

php compiler.php /javascripts [options]
php compiler.php /javascripts/myfile.js [options]

Options are:

-q, --quiet                      no output
-p, --pretend                    no changes are made
-r, --recursive                  execute the action on all subdirectories
-w, --supress_warnings           don't show compilation warnings
-l, --compilation_level          compilation level
                                 WHITESPACE_ONLY
                                 SIMPLE_OPTIMIZATIONS (default)
                                 ADVANCED_OPTIMIZATIONS
-c, --combine                    if folder is given js files are combined in all.min.js
-h, --help                       show this

Protection

Any file that returns a failure code, is larger than before, or is empty will not be saved.

Example

php compiler.php /javascripts
  compiling /javascripts/applications.js
  2887 -> 132 (102 gzip)                   = 4% (3% gzip)

  compiling /javascripts/social/file.js
  3136 -> 282 (240 gzip)                   = 9% (7% gzip)

  compiling /javascripts/social/app.js
  5045 -> 4 (3 gzip)                       = 0% (0% gzip)
  ...

Author

Javier Martinez Fernandez
ecentinela@gmail.com