As a response to a new thread in the ez.no forum[*], I post a
requirements document that I wrote for a YMC internal component, whose
development however has not been scheduled yet.

[*] http://ez.no/developer/forum/developer/smart_loading_of_javascript/

HtmlComponents, Requirements
Description

The Yahoo! Exceptional Performance website[1] lists rules that help
building faster websites. This requirements document describes a
component that should help in the implementation of some of these rules,
which are listed below.

   1. Make Fewer HTTP Requests
   2. Gzip Components
   3. Put Stylesheets at the Top
   4. Put Scripts at the Bottom
   5. Make JavaScript and CSS External
   6. Reduce DNS Lookups
   7. Minify JavaScript and CSS
   8. Remove Duplicate Scripts 

The component's duty is to

    * provide a central place, where application components like
      templates or modules can announce their need of a javascript or
      css file

    * produce the <link> tags needed to include all required css
      components

    * produce <script> tags needed to include all required javascript

    * automatically resolve dependencies of the required javascript and
      css components and adjust the link and script tags accordingly

    * combine multiple files to one rollup file

    * automatically minify javascript and css files for production
      systems, but not for development systems 

Current implementation

A common web-application characteristic is, that the rendering of
different parts of the final HTML document is delegated to small
subsystems, i.e. modules or templates. Since the subsystem usually has
no control of the page header content and the bottom of the HTML page,
it can not place <link> and <script> tags where they should be.

Webdevelopers facing this problems commonly solve it by including all
javascript and css files on all pages. This way functionality is achived
by slowing down all other pages of a web presence.  Requirements

Based on the general picture described above, the following detailed
requirements should be solved:

    * Provide a PHP method to require the load of html components.
      Components should be required by an internal identifier.

    * Provide a registry for html components so that components can be
      required by an internal identifier rather then a fixed url.

    * Provide an interface for the manipulation of the internal
      registry.

    * Provide a PHP method to render either the final <link> or <script>
      tags for direct inclusion in the html page.

    * Automatically add additional html components according to an
      internal dependency graph.

    * Provide methods to minify and to combine html components.

    * Provide the possibility to define rollup combinations. A rollup
      combination combines multiple css or javascript files in one file.
      If all parts of a rollup files are required, then the
      HtmlComponent will not serve these parts as individual files but
      as one rollup file. The <link> or <script> tags will reflect this.

    * The HtmlComponent should support the dynamic serving of html
      components as well as a pre build functionality.

    * The HtmlComponent should support gzipping of files.

    * The component should support the Versioning of html components.
      This means, that usage of a newer component should be controllable
      at one single point instead of changing all calls to the require
      method.

    * At best, the component supports to serve different versions of the
      same html component for different pages.

    * The component should in a later version support statistical
      logging of required components for different pages. 

Design Goals

    * The component should be able to serve as a server-site version of
      the YUI-Configurator[2], but must support all major javascript
      libraries.

    * If possible, the component should become part of the eZ Components
      project. This implies to follow the development and implementation
      process of eZ Components as much as possible. 

Special Considerations

    * The component should be usable inside of eZ Publish 4, but must
      not depend on eZ Publish. So it should be possible to integrate it
      in any other PHP5 application as long as ezcBase is available.
      Dependencies on any other component should be avoided and must be
      discussed. 

    * A not yet solved problem is, that calls to the require function
      could be placed inside a template. If this template is not
      executed, because it's output is cached, then the require function
      is not called.

Glossary

    * html component: a single javascript or css file 

[1] http://developer.yahoo.com/performance/ 
[2] http://developer.yahoo.com/yui/articles/hosting/#configure 

-- 
Thomas Koch, http://www.koch.ro
YMC AG, http://www.ymc.ch
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to