Permalink
Browse files

minifying css and js

  • Loading branch information...
blackant committed Feb 6, 2011
1 parent 24f0ce5 commit b977f493b0d3df050260ff2533cf6f2ebb83172e
Showing with 9,357 additions and 5 deletions.
  1. BIN content/.DS_Store
  2. BIN public/docs/js/.DS_Store
  3. +13 −0 public/min/.htaccess
  4. +145 −0 public/min/README.txt
  5. +253 −0 public/min/builder/_index.js
  6. +36 −0 public/min/builder/bm.js
  7. +15 −0 public/min/builder/bm2.js
  8. +251 −0 public/min/builder/index.php
  9. +36 −0 public/min/builder/ocCheck.php
  10. +1 −0 public/min/builder/rewriteTest.js
  11. +43 −0 public/min/builder/test.php
  12. +168 −0 public/min/config.php
  13. +25 −0 public/min/groupsConfig.php
  14. +81 −0 public/min/index.php
  15. +1,370 −0 public/min/lib/FirePHP.php
  16. +347 −0 public/min/lib/HTTP/ConditionalGet.php
  17. +338 −0 public/min/lib/HTTP/Encoder.php
  18. +348 −0 public/min/lib/JSMin.php
  19. +1,872 −0 public/min/lib/JSMinPlus.php
  20. +566 −0 public/min/lib/Minify.php
  21. +103 −0 public/min/lib/Minify/Build.php
  22. +83 −0 public/min/lib/Minify/CSS.php
  23. +250 −0 public/min/lib/Minify/CSS/Compressor.php
  24. +270 −0 public/min/lib/Minify/CSS/UriRewriter.php
  25. +133 −0 public/min/lib/Minify/Cache/APC.php
  26. +139 −0 public/min/lib/Minify/Cache/File.php
  27. +140 −0 public/min/lib/Minify/Cache/Memcache.php
  28. +89 −0 public/min/lib/Minify/CommentPreserver.php
  29. +235 −0 public/min/lib/Minify/Controller/Base.php
  30. +78 −0 public/min/lib/Minify/Controller/Files.php
  31. +94 −0 public/min/lib/Minify/Controller/Groups.php
  32. +210 −0 public/min/lib/Minify/Controller/MinApp.php
  33. +87 −0 public/min/lib/Minify/Controller/Page.php
  34. +118 −0 public/min/lib/Minify/Controller/Version1.php
  35. +245 −0 public/min/lib/Minify/HTML.php
  36. +193 −0 public/min/lib/Minify/HTML/Helper.php
  37. +157 −0 public/min/lib/Minify/ImportProcessor.php
  38. +137 −0 public/min/lib/Minify/Lines.php
  39. +47 −0 public/min/lib/Minify/Logger.php
  40. +37 −0 public/min/lib/Minify/Packer.php
  41. +187 −0 public/min/lib/Minify/Source.php
  42. +142 −0 public/min/lib/Minify/YUICompressor.php
  43. +199 −0 public/min/lib/Solar/Dir.php
  44. +74 −0 public/min/utils.php
  45. +2 −5 templates/index.html
View
Binary file not shown.
View
Binary file not shown.
View
@@ -0,0 +1,13 @@
+<IfModule mod_rewrite.c>
+RewriteEngine on
+
+# You may need RewriteBase on some servers
+#RewriteBase /min
+
+# rewrite URLs like "/min/f=..." to "/min/?f=..."
+RewriteRule ^([bfg]=.*) index.php?$1 [L,NE]
+</IfModule>
+<IfModule mod_env.c>
+# In case AddOutputFilterByType has been added
+SetEnv no-gzip
+</IfModule>
View
@@ -0,0 +1,145 @@
+The files in this directory represent the default Minify setup designed to ease
+integration with your site. This app will combine and minify your Javascript or
+CSS files and serve them with HTTP compression and cache headers.
+
+
+RECOMMENDED
+
+It's recommended to edit config.php to set $min_cachePath to a writeable
+(by PHP) directory on your system. This will improve performance.
+
+
+GETTING STARTED
+
+The quickest way to get started is to use the Minify URI Builder application
+on your website: http://example.com/min/builder/
+
+
+MINIFYING A SINGLE FILE
+
+Let's say you want to serve this file:
+ http://example.com/wp-content/themes/default/default.css
+
+Here's the "Minify URL" for this file:
+ http://example.com/min/?f=wp-content/themes/default/default.css
+
+In other words, the "f" argument is set to the file path from root without the
+initial "/". As CSS files may contain relative URIs, Minify will automatically
+"fix" these by rewriting them as root relative.
+
+
+COMBINING MULTIPLE FILES IN ONE DOWNLOAD
+
+Separate the paths given to "f" with commas.
+
+Let's say you have CSS files at these URLs:
+ http://example.com/scripts/jquery-1.2.6.js
+ http://example.com/scripts/site.js
+
+You can combine these files through Minify by requesting this URL:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js
+
+
+SIMPLIFYING URLS WITH A BASE PATH
+
+If you're combining files that share the same ancestor directory, you can use
+the "b" argument to set the base directory for the "f" argument. Do not include
+the leading or trailing "/" characters.
+
+E.g., the following URLs will serve the exact same content:
+ http://example.com/min/?f=scripts/jquery-1.2.6.js,scripts/site.js,scripts/home.js
+ http://example.com/min/?b=scripts&f=jquery-1.2.6.js,site.js,home.js
+
+
+MINIFY URLS IN HTML
+
+In (X)HTML files, don't forget to replace any "&" characters with "&amp;".
+
+
+SPECIFYING ALLOWED DIRECTORIES
+
+By default, Minify will serve any *.css/*.js files within the DOCUMENT_ROOT. If
+you'd prefer to limit Minify's access to certain directories, set the
+$min_serveOptions['minApp']['allowDirs'] array in config.php. E.g. to limit
+to the /js and /themes/default directories, use:
+
+$min_serveOptions['minApp']['allowDirs'] = array('//js', '//themes/default');
+
+
+GROUPS: NICER URLS
+
+For nicer URLs, edit groupsConfig.php to pre-specify groups of files
+to be combined under preset keys. E.g., here's an example configuration in
+groupsConfig.php:
+
+return array(
+ 'js' => array('//js/Class.js', '//js/email.js')
+);
+
+This pre-selects the following files to be combined under the key "js":
+ http://example.com/js/Class.js
+ http://example.com/js/email.js
+
+You can now serve these files with this simple URL:
+ http://example.com/min/?g=js
+
+
+GROUPS: SPECIFYING FILES OUTSIDE THE DOC_ROOT
+
+In the groupsConfig.php array, the "//" in the file paths is a shortcut for
+the DOCUMENT_ROOT, but you can also specify paths from the root of the filesystem
+or relative to the DOC_ROOT:
+
+return array(
+ 'js' => array(
+ '//js/file.js' // file within DOC_ROOT
+ ,'//../file.js' // file in parent directory of DOC_ROOT
+ ,'C:/Users/Steve/file.js' // file anywhere on filesystem
+ )
+);
+
+
+COMBINE MULTIPLE GROUPS AND FILES IN ONE URL
+
+E.g.: http://example.com/min/?g=js&f=more/scripts.js
+
+Separate group keys with commas:
+ http://example.com/min/?g=baseCss,css1&f=moreStyles.css
+
+
+FAR-FUTURE EXPIRES HEADERS
+
+Minify can send far-future (one year) Expires headers. To enable this you must
+add a number to the querystring (e.g. /min/?g=js&1234 or /min/f=file.js&1234)
+and alter it whenever a source file is changed. If you have a build process you
+can use a build/source control revision number.
+
+You can alternately use the utility function Minify_getUri() to get a "versioned"
+Minify URI for use in your HTML. E.g.:
+
+<?php
+require $_SERVER['DOCUMENT_ROOT'] . '/min/utils.php';
+
+$jsUri = Minify_getUri('js'); // a key in groupsConfig.php
+echo "<script src='{$jsUri}'></script>";
+
+$cssUri = Minify_getUri(array(
+ '//css/styles1.css'
+ ,'//css/styles2.css'
+)); // a list of files
+echo "<link rel=stylesheet href='{$cssUri}'>";
+
+
+DEBUG MODE
+
+In debug mode, instead of compressing files, Minify sends combined files with
+comments prepended to each line to show the line number in the original source
+file. To enable this, set $min_allowDebugFlag to true in config.php and append
+"&debug=1" to your URIs. E.g. /min/?f=script1.js,script2.js&debug=1
+
+Known issue: files with comment-like strings/regexps can cause problems in this mode.
+
+
+QUESTIONS?
+
+http://groups.google.com/group/minify
Oops, something went wrong.

0 comments on commit b977f49

Please sign in to comment.