README.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.
  4. RECOMMENDED
  5. It's recommended to edit config.php to set $min_cachePath to a writeable
  6. (by PHP) directory on your system. This will improve performance.
  7. GETTING STARTED
  8. The quickest way to get started is to use the Minify URI Builder application
  9. on your website: http://example.com/min/builder/
  10. MINIFYING A SINGLE FILE
  11. Let's say you want to serve this file:
  12. http://example.com/wp-content/themes/default/default.css
  13. Here's the "Minify URL" for this file:
  14. http://example.com/min/?f=wp-content/themes/default/default.css
  15. In other words, the "f" argument is set to the file path from root without the
  16. initial "/". As CSS files may contain relative URIs, Minify will automatically
  17. "fix" these by rewriting them as root relative.
  18. COMBINING MULTIPLE FILES IN ONE DOWNLOAD
  19. Separate the paths given to "f" with commas.
  20. Let's say you have CSS files at these URLs:
  21. http://example.com/scripts/jquery-1.2.6.js
  22. http://example.com/scripts/site.js
  23. You can combine these files through Minify by requesting this URL:
  24. http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
  25. SIMPLIFYING URLS WITH A BASE PATH
  26. If you're combining files that share the same ancestor directory, you can use
  27. the "b" argument to set the base directory for the "f" argument. Do not include
  28. the leading or trailing "/" characters.
  29. E.g., the following URLs will serve the exact same content:
  30. http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
  31. http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
  32. MINIFY URLS IN HTML
  33. In (X)HTML files, don't forget to replace any "&" characters with "&".
  34. SPECIFYING ALLOWED DIRECTORIES
  35. By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
  36. you'd prefer to limit Minify's access to certain directories, set the
  37. $min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
  38. to the /js and /themes/default directories, use:
  39. $min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
  40. GROUPS: FASTER PERFORMANCE AND BETTER URLS
  41. For the best performance, edit groupsConfig.php to pre-specify groups of files
  42. to be combined under preset keys. E.g., here's an example configuration in
  43. groupsConfig.php:
  44. return array(
  45. 'js' => array('//js/Class.js', '//js/email.js')
  46. );
  47. This pre-selects the following files to be combined under the key "js":
  48. http://example.com/js/Class.js
  49. http://example.com/js/email.js
  50. You can now serve these files with this simple URL:
  51. http://example.com/min/?g=js
  52. GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
  53. In the groupsConfig.php array, the "//" in the file paths is a shortcut for
  54. the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
  55. or relative to the DOC_ROOT:
  56. return array(
  57. 'js' => array(
  58. '//js/file.js' // file within DOC_ROOT
  59. ,'//../file.js' // file in parent directory of DOC_ROOT
  60. ,'C:/Users/Steve/file.js' // file anywhere on filesystem
  61. )
  62. );
  63. FAR-FUTURE EXPIRES HEADERS
  64. Minify can send far-future (one year) Expires headers. To enable this you must
  65. add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
  66. and alter it whenever a source file is changed. If you have a build process you
  67. can use a build/source control revision number.
  68. If you serve files as a group, you can use the utility function Minify_groupUri()
  69. to get a "versioned" Minify URI for use in your HTML. E.g.:
  70. <?php
  71. // add /min/lib to your include_path first!
  72. require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
  73. $jsUri = Minify_groupUri('js');
  74. echo "<script type='text/javascript' src='{$jsUri}'></script>";
  75. DEBUG MODE
  76. In debug mode, instead of compressing files, Minify sends combined files with
  77. comments prepended to each line to show the line number in the original source
  78. file. To enable this, set $min_allowDebugFlag to true in config.php and append
  79. "&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
  80. Known issue: files with comment-like strings/regexps can cause problems in this mode.
  81. QUESTIONS?
  82. http://groups.google.com/group/minify