Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Filter_Minify_Css Component Proposal

Proposed Component Name Zend_Filter_Minify_Css
Developer Notes
Proposers Nick Daugherty
Zend Liaison TBD
Revision 1.0 - 23 April 2010: Initial Draft. (wiki revision: 29)

Table of Contents

1. Overview

Zend_Filter_Minify_Css is a filter to reduce the size of CSS strings and files, resulting in faster client downloads

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will minify Css code.
  • This component will implement Zend_Filter_Interface
  • This component will generate valid Css code
  • This component will provide an adapter system for implementing different minification solutions
  • This component will provide options for control of minification (such as opting not to remove comments, for example)

4. Dependencies on Other Framework Components

  • Zend_Filter_Exception
  • Zend_Filter

5. Theory of Operation

Minifying Css leads to faster load times on the client by reducing the overall size of Css code. This component aims to perform the work of removing comments, extra whitespace, etc while retaining the familiar Zend_Filter interface.

This component can be integrated into other framework components, such as HeadStyle view helper for automatic Css minification.

The component is used like any other Zend_Filter_* component, passing the string to be minified to the filter() method.

6. Milestones / Tasks

  • Milestone 1: design notes will be published here
  • Milestone 2: Working prototype checked into the incubator supporting minification of Css strings
  • Milestone 3: Unit tests exist, work, and are checked into SVN.
  • Milestone 4: Initial documentation exists.

7. Class Index

  • Zend_Filter_Minify_Exception
  • Zend_Filter_Minify_Css
  • Zend_Filter_Minify_Interface
  • Zend_Filter_Minify_Css_RegEx

8. Use Cases


Minifying a string of Css

9. Class Skeletons



Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Apr 27, 2010


    <p>What about multiple files and saving the result to a single file to decrease requests?</p>

    <p>That is a good addition, as well combining files inside a dir.</p>

    <p>And why not do this by request. We know what files will be used because of HeadStyle Helper. </p>

    <p>just some toughs in.</p>

    <p>Best Regards,<br />
    Bento Vilas Boas</p>

    1. Apr 27, 2010

      <p>That is the ultimate goal I had in mind when proposing this. I think we should have a new View Helper component for minifying CSS/JS/HTML, or modify the existing HeadStyle/HeadScript helpers to have an option for automatically minifying it's output. The filter components are 'dumb'; they just do the grunt work of minification and it's up to other components in ZF to use them.</p>

      <p>A user could always create a controller that took one or many CSS/JS files as arguments and produced a minified, combined file as output. Ideally ZF could do this itself though...such as with the HeadLink and HeadScript helpers...they know which <strong>files</strong> are on the page, and they can create one <script> or <style> tag from them with some GET parameters corresponding to the individual files, formatted in a way that ZF can understand when the actual file is requested by browser. OR it could do the minification/combination itself, save the combined result into a publically accessible file (from the components configuration), and use the new filename (a hash) when it is printed to page. Then it's there for when the file is actually requested.</p>

      <p>Since minification is fairly expensive, ZF should be smart about this...IE, it should cache these combined files and only invalidate the cache if a file has been seems like Zend_Cache_Frontend_File might be a candidate for this.</p>

  2. Jul 14, 2010

    <p>Hi Nick,</p>

    <p>your minify filters could be very helpful!</p>

    <p>Here are my points to all of it:</p>
    <li>Adapter based to support different external applications like yui compressor</li>
    <li>Use of PluginLoader to load different adapters</li>
    <li>What about the namespace Zend_Filter_Compress_*</li>
    <li>Add a filter for PHP -> php_strip_whitespace or using tokens</li>

    1. Jul 21, 2010

      <p>Interesting suggestion regarding the Zend_Filter_Compress_* namespace, i am interested in what other contributors think about it.</p>

  3. Aug 24, 2010

    <ac:macro ac:name="note"><ac:rich-text-body><p><strong>Community Review Team Recommendation</strong></p>

    <p>The CR Team recommends this component be included as is for 1.11 and 2.0 into the Zend_Filter_Minify namespace</p>