jeMinifyJsCssPlugin - 0.0.2

Unobstrusive javascript/stylesheet minifier

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

unobstrusive js/css minification

It is Heavily based on sfCombineFilter.

  • i merely added delivery by apache static file instead of php (40 req/s for php delivery, 1200req/s for apache static)
  • i added a default htaccess to cache the minified js/css efficiently in the browser
  • i fixed some yml configuration issue
  • it is not yet finished

jeMinifyJsCss plugin

The jeMinifyJsCss is an implementation of the [http://rakaz.nl/extra/code/combine CSS and Javascript Combiner] by Niels Leenheer. It makes your pages load faster by combining and compressing javascript and css files.

This filter provides means to automatically combine your included javascripts and stylesheets into one request each. All of the included files are combined into a single large file. Gzip compression is determined by the "compressed" setting in settings.yml The resulting file is cached and used every time that particular combination of files is used. If any of the files are changed a new cache is automatically created.

The symfony filter looks at all of the javascripts and stylesheets resources specified in the current response, and automatically creates a string that combines all of the names together. When your visitors request this special file, they will get one large file.

For example, if you are including the following javascripts on every page:

  • /js/prototype.js
  • /js/builder.js
  • /js/effects.js
  • /js/dragdrop.js
  • /js/slider.js

Using the combine script, you can combine all of these files into a single packed.js file

Features

  • Support for automatic combination of javascript, css, or both
  • Support for script exclusions (mainly for scripts that are incompatible with being packed like tiny_mce)
  • Automatically replaces relative paths in css files with actual paths
  • Support for css filtered paths for additional paths that need to be removed from the file path before replacing relative paths in the css files
  • Cache that refreshes automatically when source files are changed
  • Option to minimize the packed.js with JsMinEnh
  • Option to safe minimize the css
  • Options to only pack the javascript or css in /packed/js or /packed/css
  • Filter utilizes client side caching to send 403 for unchanged cache files

Installation

symfony plugin-install http://plugins.symfony-project.com/jeMinifyJsCss

Usage

Enable the filter

  • In app/config/filters.yml, add the jeMinifyJsCss. This must come AFTER "common":

    rendering: web_debug: security: cache: common: jeMinifyJsCss: class: jeMinifyJsCss flash: execution: ~

  • In app/config/settings.yml

add jeMinifyJsCss to enabled_modules: []

  • All settings are made in application/config/app.yml. See plugins/jeMinifyJsCssPlugin/config/app.yml for defaults and examples.
  • You can turn off the filter all together for javascript or css by setting those parameters to "false". You can turn pack on or off by setting minimize_js or minimize_css.
  • You can combine only the files in /packed/js and /packed/css by setting root_js_only and root_css_only to true.
  • If you want the combine filter to only be available in the prod environment make a seperate enabled_modules setting for dev: and prod: and leave jeMinifyJsCss out of dev:.

Known Issues

  • Internet Explorer 6 has problems with large javascript files when gzip compression is on. If you experience strange issues with your pages in IE6, set compressed: off for you environment in settings.yml and it should resolve the problem
  • Requires a memory_limit of 32M or more in php.ini.
  • Not really an issue, but the cache/packed_files cache namespace does not get cleared with symfony cc. This is desirable as the packed files are static data and should only need to be cleared if you are making a lot of changes to the files being packed.
  • If you have an issue with your javascript throwing errors only when minimized, look for missing semi-colons in your javascript code. Each code block enclosed within {} should be followed by a semi-colon.
  • There may be some issues with script include order if you have .pjs, .pcss files, or script exclusions. It's generally best to ensure that packed.js is included before anything else.

Changelog

2007-07-26 | 0.1.0 beta

Initial public release.

2007-08-02 | 0.1.1 beta

Changes by Kiril Angov: - Fixes regular expression to match '^/css/' - Fixes issues when included files outside of root css and js directories. - New: Option to minify the js using JSMin.

2008-07-21 | 0.1.2 beta

Changes by Benjamin Runnels: - Moved cache generation/management into the filter - Removed .htaccess modification requirements - added minimize_js and minimize_css options to the filter - added client side caching for the packed files and improved the request name so it will cache properly - added routing rules to route to the jeMinifyJsCss module - added non-harmfull css minimizer - added path replacement in css files to resolve relative path issues - switched to JsMinEnh class to improve memory usage and speed of javascript minimizing

2009-01-29 | 0.1.3 beta

  • symfony 1.2 support added