WP-Compress-HTML
This is the homepage of the WP-Compress-HTML plugin for Wordpress.
WP-Compress-HTML reduces HTML file size by removing unnecessary white space from the HTML document created by the WordPress blog.
What is WP-Compress-HTML all about?
Coders and template designers like to use spaces, carriage returns, new lines, tabs and indentation to make their HTML documents human-readable. This helps collaboration and debugging of the HTML document. However, all these features add to the filesize of the resultant HTML document. This structural information is totally ignored by browsers.
This plugin removes spaces, carriage returns, new lines and tabs from your HTML document. You can therefore freely use these features while writing HTML, safe in the knowledge that it will not bloat the final HTML document.
With this plugin you can also mark areas of your HTML template where you want to preserve white space - for example - in areas containing Javascript which needs carriage returns and new lines to function correctly.
HTML Comments are not affected by this plugin.
Installation instructions
- Download the WP-Compress-HTML plugin.
- Extract the wp_compress_html.php file and upload to the ‘/wp-content/plugins/’ directory.
- Activate the plugin through the ‘Plugins’ menu in WordPress
- If there are areas which you do NOT want compression to be applied, simply enclose each area with a pair of < ––wp-compress-html––> tags. Use one at the beginning and one at the end of the area you want to protect. Drop in a < ––wp-compress-html no compression––> tag within each area marked in this way to tell the plugin that area is not to be compressed.
Frequently Asked Questions
- Why do I need this plugin?
When you are coding your HTML template, you will almost certainly want to add spaces, tabs and carriage returns to the document. This helps you to read it, but this information is ignored by the browser and transmitting it to the browser is a waste of bandwidth. It bloats your files and slows your site down. This plugin will remove all this unnecessary “white space”.
- How much savings can be achieved with this plugin?
We have seen savings of upto 5-10%, depending on how much “white space” is in your HTML templates. Even if this does not sound like much, it certainly adds up on a busy site with a high number of page views.
- How do I mark areas that should not be compressed?

Look at this screenshot to see how to mark areas in your template that should not be compressed. Simply add the tags in red to wrap around areas that should not be compressed. - Does it work for WordPress version x.x.x?
The plugin has been tested with WordPress version 2.5 only.
12 May 2008 Mandar




























Absolutely fantastic plugin! Thank you very much for sharing.
Steve
This seems a very useful plugin. However, I wonder a thing, it speeds up the download of the files, however while removing white space it uses CPU and won’t it slow down the creation of the page?
If it creates the pages slower, even if it creates smaller files, we won’t earn many things. Is it a problem, will it effect CPU usage a lot.
Hi Ferhad, you are right, the initial page generation will increase CPU usage a little bit.
However, most web servers (including Apache) will cache the page after it is generated. It will do this automatically.
Also, if you install a plugin such as WP Super Cache, it will also cache the page on the server.
So once the page has been generated, the subsequent hits will not take any further CPU cycles.
Thanks for the reply. I have been using it since I left the previous comment to test it. It’s great, before it all my theme pages were one line and hard to edit, after it everything is great. I don’t use a cache plugin but I haven’t noticed an important increase in my shared server’s CPU usage. That’s great, thanks.
Please fix wp-compress to work well with All in One Seo Pack script, when I set custom Title with AIOSP in post your script removes them, I’m very thankful to you for this script it really saves around 10-15% of traffic and hope this gonna be fixed soon, take care!
Good job. But, an option to automatically leave tags untouched would be great.
Any suggestions for how this could be done with PHP?
have you, or will you, test this plug-in with wordpress 2.7? I just want to know it is safe to use.
Hi,
Yes, this plugin is tested with Wordpress 2.7 and works fine.
Let me know if you have any problems with it.
Mandar.
hi,
i really like it:)
thanks for this plugin
i modified it a little so ALL code is cleaned (without need to use your stopcode).
see it - i think you find out, what i’ve changed
best regards,
thomas
Thanks for the code Thomas, I will incorporate your changes into the plugin.
Mandar.
Hey, the plug in is not working for my WP 2.7.1 install… It returns the beginning of the , no close header tag, no body tags, and no close html tag… after all my css links all there is is two tags. Very strange! So my whole page appears to be missing when the plug in is activated. Let me know if you’d like to see the source! -Joe
Subscribing to follow-up comments, hehe
Hmmm. Very strange indeed LOL. This isn’t something I’ve found before. I will look into it.
Hi there,
I found a incompability bug between Viper’s Video Quicktags & WP-Compress-HTML.
If WP-Compress-HTML is activated, videos aren’t showing up, just a link or a preview image.
Any ideas?
I wasn’t aware of this, thanks for letting me know.
Mandar.