sfOptimizeStyleAndScriptPlugin - 0.0.2

web optimizer

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source | Show as Markdown

sfOptimizeStyleAndScriptPlugin plugin

Merge and compress stylesheets and javascripts files


  • Merge js and css files
  • Automaticly replace css url() path attribute by the new right path
  • Compress merged files (use JsMin and CssMin, see lib/vendor/ dir)
  • Cache them in the http web dir


  • No Unit Test and Not strongly tested.
  • Not tested on version > symfony 1.0.x
  • Js compression not work with sfDebugBar
  • css or js include not supported, they will be not merged and urls can be wrong. (for scriptaculous, include manually every files you need, not just scriptaculous.js)


  • Make sure sf_web_dir is well setted, otherwise add in app/config.php :

       'sf_web_dir'     => SF_ROOT_DIR.DIRECTORY_SEPARATOR.<web_dir>
  • Add the filter in your filter.yml

      class: sfOptimizeStyleAndScript
  • Clear Cache (symfony cc)


  • In settings.yml file, (this is default values):

      optimizer_dir:            cache        # cache directory in http web dir
      optimizer_js_lifetime:    86400        # lifetime for js file, in second
      optimizer_js_compressed:  false        # compress merged result with JsMin
      optimizer_css_lifetime:   86400        # lifetime for ccs file, in second
      optimizer_css_compressed: false        # compress merged result with JsMin


Michel Meyer


Douglas Crockford's JSMin JavaScript minifier http://www.crockford.com/javascript/jsmin.html and http://code.google.com/p/jsmin-php/

for CssMin look at: http://code.google.com/p/cssmin/

Thanks to all of you !