sfScriptUniterPlugin - 0.3.0

Packs all javascripts and css files.

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


If you have lots of js, that slower your application you can easily speed it up - just pack all you script in one file. This plugin will help you to perform that


Setup of this plugin is very simple. First, enable the plugin in /config/ProjectConfiguration.class.php

class ProjectConfiguration extends sfProjectConfiguration
  public function setup()



Next step is to add sfScriptUniteFilter in your application's filter.yml:

  class: sfScriptUniterFilter
  enabled: true
    output_js: all.js
    output_css: all.css
    # Can be stylesheet, javascript or all
    type: all
    compressor_js:  sfScriptUniterJsMinCompressor
    compressor_css: sfScriptUniterCssMinCompressor

Filter's parameters description:

  • output_js - the output js file's name
  • output_css - the output_css file's name
  • type - uniter type - could be all (for css and js), javascript (only js), stylesheet(only css)
  • compressor_js - class compressor for javascripts
  • compressor_css - class compressor


There are some libraries for minifying scripts and css. For example JsMinify or YiiCompressor Tools. It is a good strategy not only to pack all scripts and css in one file but although minify it to reduce the traffic and increase the page loading speed.

Thats why ScriptUniter library includes the ScriptCompressor interface, which helps you to compress the scripts using the library you prefer.

By the default, the object of ScriptUniter uses instance of BlankScriptCompressor. In fact this class is doing nothing. But you could easily create new class. For example:

class MegaCompressor implements ScriptCompressor {

    public function compress($text) {
       //MegaCompress you favorite compression lib
       return MegaCompressLib::make($text);

Now modify filter.yml :

     class: sfScriptUniterFilter
     enabled: true
       compressor_js: MegaCompressor

and clear the symfony's cache.

Starting with version 0.2.0 two new script compressors are added: sfScriptUniterJsMinCompressor(http://github.com/rgrove/jsmin-php/) and sfScriptUniterCssMinCompressor(http://code.google.com/p/cssmin/)

Debug Panel

Starting with version 0.3.0 the debug panel is available. To activate the panel add to ProjectConfiguration.class.php the next code:

class ProjectConfiguration extends sfProjectConfiguration{

 public function setup() {


  $this->dispatcher->connect('debug.web.load_panels', array(


Activating this panel helps to ignore the copressing and pcaking script and css files


For correct work, make shure folders /web/js and /web/css have write permissions!


If you have some question or suggestion, write to roll.dev at gmail.com