My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

This project does 2 major things: 1. It makes sure you include every css and js only once in every page you generate. This is very helpful when using templating, since you want to attach the template css to the template, but if you reuse the template the css will be called several times, not necessarily causing any damage, but there is a slight performance hit, and problems in firebug (and we don't want that!) 2. If you set $GENERAL_CONFIG['aggregate'] = true, then this code starts aggregating the css and js files into one large file. This helps decrease calls to http, really boosting up your site's performance.

USAGE: 1. Create the cache table (see notices) 2. Create the code accessing the cache table, basically this is a class supporting the functions $db->GetCacheInfo, $db->SetCacheInfo, and $db->CreateCacheInfo. 3. require js_css_aggregator in your code, and either call js_include_once(), or css_include_once() as necessary. 4. to output the cache into your html, the code provides the global variables $all_js and $all_css, which you just echo in your html. To provide the best performace for your site, echo $all_css at the top of your html, and echo $all_js at the bottom of your html.

NOTICES: 1. To use the aggregator you need the following db table: CREATE TABLE cache (

id int(11) NOT NULL auto_increment, cache_name varchar(100) collate utf8_unicode_ci NOT NULL, cache_content text collate utf8_unicode_ci NOT NULL, version varchar(100) collate utf8_unicode_ci NOT NULL, last_update datetime NOT NULL, last_update_unix bigint(20) unsigned NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY cache_name (cache_name)
) I didn't add the database code to the project yet because it is too customized for the project I wrote the aggregator for. So this google code is for php programmers not afraid to hack and customize code to fit their own projects. I am hoping that in the near future I will have a quiet weekend to turn this code into a closed component. 2. The code currently creates a different cache per page, but that is easily modifiable. 3. There is different code producing the js and css includes, but they are virtually identical, I will probably pretty up this code when I have the time.

WISHLIST: 1. Wrap this code in a normal class to get rid of the horrible global variables. 2. Split the parameter $GENERAL_CONFIG['aggregate'] into $GENERAL_CONFIG['js-aggregate'] and $GENERAL_CONFIG['css-aggregate'], so people can choose whether they want to aggregate js or css only. 3. Add the database code to the class so people don't have to write it themselves. 4. That someone would either volunteer to help me with this, or that someone will take this and rewrite it into something more useful for the community :)

Powered by Google Project Hosting