diff --git a/README.md b/README.md index 5309b24..8443b61 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A simple set of minifying scripts for CSS and Javascript ## Basic Use: ## -1. Figure out your file paths, and set them in css.php and js.php. +1. Figure out your file paths, and set them in `config/config.php`. 2. Add your css and javascript files to groups, in `config/css_groups.php` and `config/js_groups.php` respectively 3. Point your CSS links in your HTML to `css.php/g/[group_name]`, and likewise your javascript to `js.php/g/[group_name]` 4. Add a folder named "cache" to your js path diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..4b8440c --- /dev/null +++ b/config/config.php @@ -0,0 +1,36 @@ + false))); - file_put_contents($cache_file, $js); + $js = trim(JShrink::minify(get_files(), array('flaggedComments' => false))); + $cs = file_put_contents($cache_file, $js); + + //Make sure cache file gets created/updated + if($cs === FALSE) + { + die("Cache file was not created. Make sure you have the correct folder permissions."); + } +} +else if(isset($_GET['debug'])) +{ + $js = get_files(); } else { $js = file_get_contents($cache_file); } +// -------------------------------------------------------------------------- + +//This GZIPs the js for transmission to the user +//making file size smaller and transfer rate quicker +ob_start("ob_gzhandler"); + header("Content-Type: application/x-javascript; charset=utf8"); header("Cache-control: public, max-age=691200, must-revalidate"); header("Last-Modified: ".gmdate('D, d M Y H:i:s', $last_modified)." GMT"); -header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($base_path.'js.php') + 691200))." GMT"); +header("Expires: ".gmdate('D, d M Y H:i:s', (filemtime($this_file) + 691200))." GMT"); echo $js;