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

Using one file, instead of having clients download several CSS and JavaScript files, phpFlair allows you to serve them one CSS and one JavaScript file.

This allows your Web page to load and respond more quickly.

GZip encoding further reduces the time for your Web page to load and reduces bandwidth used by your site. Client-side cache headers allow clients to download your CSS and JavaScript once, instead of every page load, unless you make changes to your CSS or JavaScript file(s), in which case the phpFlair cache is automatically updated.

The combined CSS or JavaScript file created by phpFlair contains your code unmodified, just combined and GZipped.

Example usage of phpFlair

Replace several script calls with some phpflair

<!DOCTYPE html>
<html>
<head>

<!-- group your css together -->
<link type="text/css" rel="stylesheet" href="phpflair.php?css=cssA" />

<!-- large required script -->
<script type="text/javascript" src="phpflair.php?js=jquery"></script>
<!-- group your scripts together -->
<script type="text/javascript" src="phpflair.php?js=jsA"></script>
<!-- or list your scripts -->
<script type="text/javascript" src="phpflair.php?js=script1|script2|script3"></script>

</head>

Configure phpflair.php

<?php

..
// $config['sources'] - list your files to combine via phpflair
if ($_REQUEST['css'] == 'cssA') {
    $asset_dir = 'flair/';
    $config['sources'] = array(
        $asset_dir.'core/core.css',
        $asset_dir.'jqueryisotope/jquery.isotope.css',
        $asset_dir.'jquerycolorbox/jquery.colorbox.css',
        $asset_dir.'jquerystatusmessageq/jquery.statusmessageQ.css',
        $asset_dir.'login/login.css',
        $asset_dir.'site/button.css',
        $asset_dir.'site/menu.css',
        $asset_dir.'site/user.css'
    );
..
if ($_REQUEST['js'] == 'jquery') {
    $config['type'] = 'js';
    $config['sources'] = array('flair/jquery/jquery.min.js');

| else if ($_REQUEST['js'] == 'jsA') {
    $asset_dir = 'flair/';
    $config['sources'] = array(
        $asset_dir.'core/core.js',
        $asset_dir.'jqueryisotope/jquery.isotope.js',
        $asset_dir.'jquerycolorbox/jquery.colorbox.js',
        $asset_dir.'jqueryform/jquery.form.js',
        $asset_dir.'jqueryblockui/jquery.blockUI.js',
        $asset_dir.'jquerystatusmessageq/jquery.statusmessageQ.js',
        $asset_dir.'phpjs/php_md5.js',
        $asset_dir.'phpjs/php_utf8_encode.js',
        $asset_dir.'login/login.js',
        $asset_dir.'site/user.js'
    );
..
// where to store combine files; needs to be writable to use (recommended) or set to false to not use
$config['cache_path'] = 'cache';
..
?>
Powered by Google Project Hosting