Minify

Minify - Combines, minifies, and caches JavaScript and CSS files on demand to speed up page loads. 

 Minify is a PHP5 app that helps you follow several of Yahoo!'s Rules for High Performance Web Sites.

 It combines multiple CSS or Javascript files, removes unnecessary whitespace and comments, and serves them with gzip encoding and optimal client-side cache headers.


Minify in Use

Before
After
The stats above are from a brief walkthrough which shows how easy it is to set up Minify on an existing site. It eliminated 5 HTTP requests and reduced JS/CSS bandwidth by 70%.
The design is somewhat similar to Yahoo's Combo Handler Service, except that Minify can combine any local JS/CSS files you need for your page.

Minify integrated into other Projects/Plugins

Features

  • Combines and minifies multiple CSS or JavaScript files into a single download
  • Uses an enhanced port of Douglas Crockford's JSMin library and custom classes to minify CSS and HTML
  • Caches server-side (files/apc/memcache) to avoid doing unnecessary work
  • Responds with an HTTP 304 (Not Modified) response when the browser has an up-to-date cache copy
  • Most modules are lazy-loaded as needed (304 responses use minimal code)
  • Automatically rewrites relative URIs in combined CSS files to point to valid locations
  • With caching enabled, Minify is capable of handling hundreds of requests per second on a moderately powerful server.
  • Content-Encoding: gzip, based on request headers. Caching allows it so serve gzipped files faster than Apache's mod_deflate option!
  • Test cases for most components
  • Easy integration of 3rd-party minifiers
  • Separate utility classes for HTTP encoding and cache control

Requirements

  • PHP 5.1.6 / command-line tools require 5.3
  • The commonly installed zlib extension is recommended for HTTP encoding functionality.
  • Version 1.0.1 required PHP 5.2.1+.


* Set the document root to be the path of the "site root":

// Set the document root to be the path of the "site root"$min_documentRoot = substr(__FILE__, 0, -15);
// Set $sitePrefix to the path of the site from the webserver's real docrootlist($sitePrefix) = explode('/min/index.php', $_SERVER['SCRIPT_NAME'], 2);
// Prepend $sitePrefix to the rewritten URIs in CSS files$min_symlinks['//' . ltrim($sitePrefix, '/')] = $min_documentRoot;




Source from: https://code.google.com/p/minify/


留言

這個網誌中的熱門文章

How to PHP export to Excel 2

html viewport meta