WPSCMin is a plugin to a plugin: A plugin for the static-caching WordPress plugin WP Super Cache, it uses Minify to strip whitespace and comments from your web pages. Your super-fast static-cached pages will shrink a further 5-20% in size.
If you used a previous version of my code, the good news is that it’s now a fully fledged plugin to WP Super Cache, so it’s an easy install (no more patches! no more breakage when Super Cache changes!).
What it does
- Adds a handy “on/off” control to the Super Cache options screen in the WordPress backend. So, you can turn it off for debugging, or to read your pretty indented source code.
What it doesn’t do
- Minify dynamic pages. The CPU cost of minifying a dynamic page greatly outweighs the bandwidth savings — minifying HTML only makes sense in concert with a static-caching solution like Super Cache, or if you’re using a caching front-end proxy like Varnish or Squid. The whole point of my plugin is that it doesn’t waste resources minifying dynamic pages, only those cached by Super Cache.
If that didn’t make sense, or for more discussion, feel free to take a look at my original release post, where I get into greater detail.
Installation and upgrade
Last update: Updated to version 0.5 on 1/20/2011.
Requirements: PHP5. WP Super Cache 0.9.9.6+. (See advanced usage below to use with older versions of Super Cache.)
- Download the current version and unzip. Move
pluginssubdirectory of WP Super Cache. If yours is a standard WordPress install, this will be
- Download the current version of Minify and unzip. Move the
mindirectory into the
pluginssubdirectory of WP Super Cache, right next to
- Log into your site, go to the WP Super Cache config page, and scroll to the bottom. Enable HTML Minify, and you’re done!
Note to upgraders: If you’re upgrading from version 0.4, you only need to replace
WPSCMin.php with the new version of the file (and that’s it!). If you’re upgrading from version 0.3 or older (the ones with all the patches), be sure to replace your patched Super Cache files with fresh ones, and notice in the instructions above that the location of
Version 0.5 added several optional features for advanced users. Read on to learn how to:
Mark sections of HTML so that they will not be minified
If there are sections of your pages that you don’t want to minify (for instance, certain HTML comments like AdSense slot IDs), you can tell WPSCMin to skip them. Just surround whatever HTML code you don’t want minified with
<!--[/minify_skip]-->. (By the way, these “minify_skip” tags are themselves stripped when the page is minified.)
Install Minify in an alternate location or point to an existing install of Minify
Generally, having more than one copy of the Minify PHP files on your system shouldn’t cause a problem, because WPSCMin checks to see whether Minify is loaded before including it again. However, if you want to point to a Minify
min directory somewhere else on your filesystem, you can now do that.
Edit your WP Super Cache config file
wp-cache-config.php and create a new line that sets the variable
$cache_minify_path to the full filesystem path of the directory containing the Minify
min directory. It should look something like this:
// i.e. if Minify were in /some/path/to/a/dir/min $cache_minify_path = '/some/path/to/a/dir';
Use with an older (0.9.9.5 or earlier) version of WP Super Cache
To use with Super Cache versions 0.9.9.3-0.9.9.5, there’s some compatibility code you can enable by editing
WPSCMin.php. There are three commented-out lines that you will need to enable and then two lines immediately following that you must delete or comment out. These code sections are well-marked and should be easy to spot if you open
WPSCMin.php in your favorite editor and search for the text “For versions of WP Super Cache 0.9.9.5 and earlier”.
For even older versions (and this is really unsupported) of Super Cache, the above compatibility fix may work fine (it’s just untested prior to 0.9.9.3). If not, well, you should really upgrade WP Super Cache or just not worry about minifying your HTML! But, if you still aren’t deterred, take a look at the changelog and see which of the 2008-2009 releases (which require patching Super Cache) may be compatible with your version of Super Cache. Then go to the old files and installation instructions.
Comments, bug reports
Please add them here!