1 The files in this directory represent the default Minify setup designed to ease
2 integration with your site. This app will combine and minify your Javascript or
3 CSS files and serve them with HTTP compression and cache headers.
8 It's recommended to edit config.php to set $min_cachePath to a writeable
9 (by PHP) directory on your system. This will improve performance.
14 The quickest way to get started is to use the Minify URI Builder application
15 on your website: http://example.com/min/builder/
18 MINIFYING A SINGLE FILE
20 Let's say you want to serve this file:
21 http://example.com/wp-content/themes/default/default.css
23 Here's the "Minify URL" for this file:
24 http://example.com/min/?f=wp-content/themes/default/default.css
26 In other words, the "f" argument is set to the file path from root without the
27 initial "/". As CSS files may contain relative URIs, Minify will automatically
28 "fix" these by rewriting them as root relative.
31 COMBINING MULTIPLE FILES IN ONE DOWNLOAD
33 Separate the paths given to "f" with commas.
35 Let's say you have CSS files at these URLs:
36 http://example.com/scripts/jquery-1.2.6.js
37 http://example.com/scripts/site.js
39 You can combine these files through Minify by requesting this URL:
40 http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
43 SIMPLIFYING URLS WITH A BASE PATH
45 If you're combining files that share the same ancestor directory, you can use
46 the "b" argument to set the base directory for the "f" argument. Do not include
47 the leading or trailing "/" characters.
49 E.g., the following URLs will serve the exact same content:
50 http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
51 http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
56 In (X)HTML files, don't forget to replace any "&" characters with "&".
59 SPECIFYING ALLOWED DIRECTORIES
61 By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
62 you'd prefer to limit Minify's access to certain directories, set the
63 $min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
64 to the /js and /themes/default directories, use:
66 $min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
69 GROUPS: FASTER PERFORMANCE AND BETTER URLS
71 For the best performance, edit groupsConfig.php to pre-specify groups of files
72 to be combined under preset keys. E.g., here's an example configuration in
76 'js' => array('//js/Class.js', '//js/email.js')
\r
79 This pre-selects the following files to be combined under the key "js":
80 http://example.com/js/Class.js
81 http://example.com/js/email.js
83 You can now serve these files with this simple URL:
84 http://example.com/min/?g=js
87 GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
89 In the groupsConfig.php array, the "//" in the file paths is a shortcut for
90 the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
91 or relative to the DOC_ROOT:
95 '//js/file.js' // file within DOC_ROOT
96 ,'//../file.js' // file in parent directory of DOC_ROOT
97 ,'C:/Users/Steve/file.js' // file anywhere on filesystem
102 FAR-FUTURE EXPIRES HEADERS
104 Minify can send far-future (one year) Expires headers. To enable this you must
105 add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
106 and alter it whenever a source file is changed. If you have a build process you
107 can use a build/source control revision number.
109 If you serve files as a group, you can use the utility function Minify_groupUri()
110 to get a "versioned" Minify URI for use in your HTML. E.g.:
113 // add /min/lib to your include_path first!
114 require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
116 $jsUri = Minify_groupUri('js');
117 echo "<script type='text/javascript' src='{$jsUri}'></script>";
122 In debug mode, instead of compressing files, Minify sends combined files with
123 comments prepended to each line to show the line number in the original source
124 file. To enable this, set $min_allowDebugFlag to true in config.php and append
125 "&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
127 Known issue: files with comment-like strings/regexps can cause problems in this mode.
132 http://groups.google.com/group/minify