1 Incredibly Wicked Trick To Speeding Up Your Blog’s Load Time

by John Hoff on September 6, 2009

We all know attention spans on the Web are small. Make a potential first time visitor to your site wait more than a few moments for your blog to load and they’ll click away faster than you can say, “But wait!”

Here’s an incredibly easy trick you can do to reducing that “but wait”-time for your blog to load. In most cases, it’s as easy as copy & paste.

Now who doesn’t like the copy, paste, and done tutorials?

Let’s first show you what to do and then for those who are interested, we’ll talk about what we did (in easy terms).

Copy This and Put It Here


<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], ‘gzip‘)) ob_start(“ob_gzhandler”); else ob_start(); ?>

Paste A (for WordPress users)

For WordPress users, paste the code up at the very top of your header.php file (above the DOCTYPE line). If you’re not sure how to do this, see the video at the end of this tutorial.


Paste B (for static .html pages)

If your website is coded in html and not php, then what you’ll need to do is copy the code above and paste it up at the very top of each web page you want to compress (above the DOCTYPE).

The one change you’ll need to do here is change the extension of your web pages from .html to .php.

So for example, change: index.html to index.php

What Did We Do?

Without going into a bunch of techno talk, we basically instructed, through PHP, that the Web server compress files for transit to your visitors’ Web browser by use of gzip.

I’m sure you’ve seen zip files before (myfile.zip). Zip is a compression utility that takes a bunch of data and files and compresses them into one smaller size file.

By using gzip, we compressed your blog’s data into a smaller file size before sending it over to your visitor’s Web browser. As a result, your blog loads faster for your visitor.

Simple. Easy. Works.

How To Test It

Of course you’ll want proof that your site is loading quicker. You should notice a difference in load time just by clicking around your blog before and after the line is pasted in. But if you want to see actual data, head over to http://www.port80software.com and type your blog’s address in the Compression Check box.

Here’s the results for my blog. I circled the parts that showed my after compression data.


As you can see, my blog loads more than 4 times faster with the gzip compression enabled.

Also, the file size transmitted over the Internet and to my visitor’s browser was reduced from 60,241 bytes to just 12,963 bytes. That’s a 47,278 difference in file size!

Share It

This little tip has helped many people decrease how long it takes their sites to load. If you have a moment, please consider sharing it through your social networks like Stumble Upon, Twitter, etc. While you’re at it, feel free to follow me on Twitter.

{ 59 comments… read them below or add one }

Jannie Funster September 8, 2009 at 10:32 am

I did it! Yay!!!! 3.5 times faster now for me. That will no-doubt be an amazing boost in the Stumble It world.

Thank you, John. Are you this nice in “real life” too? :)
.-= Jannie Funster´s last blog ..What To Do When The Power Goes Out =-.


Jannie Funster September 8, 2009 at 10:39 am

For future readers of this post, DO THIS paste into your HTML.

It is just AMAZING how much faster my blog loads, like lightening now. Thanks again, John!
.-= Jannie Funster´s last blog ..What To Do When The Power Goes Out =-.


John Hoff September 8, 2009 at 10:13 pm

Re: Thank you, John. Are you this nice in “real life” too?
Yes, unfortunately. hehe Sometimes being too nice means being taken advantage of or thinking people think the way I do (as a person not out to steal from you); this has not always worked well for me LOL.

I’m happy it worked well for you. It’s a simple little compression you can do to speed things along.

Got your email by the way, you are a way cool chick. Thanks!


Jannie Funster September 9, 2009 at 7:44 am

Oh yah! me ‘way cool, hee-hee! :)
.-= Jannie Funster´s last blog ..What To Do When The Power Goes Out =-.


Ching Ya September 9, 2009 at 10:22 pm

Thank you John for the info. I was directed here after Jannie’s advise about the code. Appreciate you sharing the tips to speed up loading time. :-) Keep up the good work!

Social/Blogging Tracker
.-= Ching Ya´s last blog ..16 Social Bookmarking Plugins to Promote Your Posts =-.


John Hoff September 10, 2009 at 3:59 am

Hi Ching Ya, nice to see you here. Glad you stopped by and no problem about the code. It works pretty good, doesn’t it.

Maybe I’ll come up with another WP speed post here shortly.


Ching Ya September 10, 2009 at 7:43 am

That sounds great! Will be anticipating for it, surely!
Thanks John. Like Jannie said, you’re a nice guy.
Keep it up!
.-= Ching Ya´s last blog ..16 Social Bookmarking Plugins to Promote Your Posts =-.


MichaelR September 10, 2009 at 11:27 pm

Hey this is cool. Speeding up the blog loading will surely like by the readers.

Thanks for sharing it with us John.

.-= MichaelR´s last blog ..How to Improve VoIP Call Quality =-.


John Hoff September 11, 2009 at 2:38 pm

Hi HichaelR, no problem. Thanks for stopping by!


Combson Yachts September 23, 2009 at 3:10 am

I have enabled this on one of my blogs and it show great acceleration.. But my other shared hosting package doesn’t support it. What a pity, I’ll have them upgrade the apache

.-= Combson Yachts´s last blog ..Isa 600 Superyacht Review with complete photos gallery =-.


John Hoff September 23, 2009 at 4:27 am

Hello Combson, thanks for stopping by and leaving a comment.

Let me first tell you, I love your blog. What I’d give to have a yacht like, well, anyone of those.

Feel free to open a hosting account with us if you need new hosting. All our tutorials are through using our control panel.

Compressing your data before transit really does help speed things up. My buddy said he had to “change his shorts” after he saw how much improvement his blog had. That was pretty funny.

I’ll try and do a follow-up article with some more tweaks you can do to speed up load time.

Thanks again for stopping by.


Brad Ney October 12, 2009 at 8:43 am

Thanks for the tutorial.. If this works, I’ll be sure to pass this on to my readers!


Brad Ney October 12, 2009 at 8:48 am

Doesn’t seem to be working for me… My shared host must not support it either. LAME – This looked really promising.


John Hoff October 12, 2009 at 12:44 pm

Hi Brad, hey nice blog you got there. I liked the reCaptcha “Ugg Why?” image LOL. I’m not a subscriber. Do you have a Twitter account I can follow? It seems we both like toying with WordPress.

Hmm, this compression should work with most web hosts. It could be a plugin which is causing the problem. Try experimenting with pasting in the code and deactivating some plugins.

I ran into issues with this code while using the Head Cleaner and WP Minify plugins.


Brad Ney October 13, 2009 at 4:38 pm

Yea it turns out that my web host doesn’t support it… I got an email back saying that they didn’t have it installed.

You think a webhosting company wouldn’t want to save bandwidth costs in any way possible! I found another tutorial for zlib compression which is working quite well on my blog. I plan to write a post about this trick as well as the other I found. Of course you’ll get a juicy backlink!

Your blog is very professional as well. You did a great job customizing it – I look forward to reading more from you :)
.-= Brad Ney´s last blog ..BradBlogging’s 2nd Anniversary Makeover With A New Design and Mindset =-.


John Hoff October 13, 2009 at 7:40 pm

Brad, glad to see you over here and thanks for the kind words and link back. Actually, I felt my last blog design was too corporate (it was an extension of our “company’s” website [which also got a redesign]).

Since I’m really the only blog author for our company, I wanted to make this blog more of an extension of me and what I do, rather than what our company has a blog about. Glad you like it, thanks.

As I recall, zlib is simply another form of gzip. Did you need to upload a php file to the server and then call it through .htaccess?

When you’re finished with that article, would you please come back here and leave a comment with a link to it? After all, that’s what we’re all about, right? Helping everyone learn.


Brad Ney October 15, 2009 at 9:24 am

Hey John.

Tried signing on to your site yesterday, but there was a 500 error :(

You can view the post at: http://bradblogging.com/tutorials/speed-wordpress-up-3-times-as-fast-under-a-minute/ which shows you how to use zlib compression on your Wordpress blog.

I think you’re right about zlib being another form of Gzip.

I simply added the code to my header and was good to go! :D
.-= Brad Ney´s last blog ..Is Your Wordpress Slow Loading? Make It 3 Times As Fast In Under A Minute =-.


John Hoff October 15, 2009 at 10:08 am

Thanks Brad, I’m headed over there now.

The 500 error was due to some upgrades to our servers which my blog and our site is hosted on. Sorry about that but it’s all squared away now. By default, the server now has directory browsing disabled, which is a nice little security feature our customers no longer need to worry about implementing themselves.


Brad Ney October 15, 2009 at 1:31 pm

Thats cool. Directory Browsing “support” sucks on Wordpress.. I had to upload blank index.html files to each directory! ;)
.-= Brad Ney´s last blog ..Is Your Wordpress Slow Loading? Make It 3 Times As Fast In Under A Minute =-.


John Hoff October 15, 2009 at 2:29 pm

To make things a little easier on you, you can disable directory browsing through your .htaccess file (so you don’t have to create all those index files).

Put this in your root .htaccess file and no one will be able to browse directories like /themes and /plugins which may not have index files:

Options -Indexes

If you stick with the .html files, you could add a Javascript redirect to automatically redirect people away from your /plugins directory to your home page.


Antti Kokkonen November 1, 2009 at 10:51 pm

I gotta give this tip a try and see if it improves my loading speeds even further. And John Hoff’s tip about the .htaccess above is spot on too…

Speaking of .htaccess, you can do gzip compression through htaccess too (the target files). If requires mod_deflate to be supported by the host (Apache 2.0 I think). mod_gzip is available for hosts not supporting mod_deflate. The code is relatively long, so I won’t paste it here, but you should find it if you search the web for “htaccess rules mod_deflate” or such.
.-= Antti Kokkonen´s last blog ..Analyzing the State of the Blogosphere 2009 =-.


John Hoff November 2, 2009 at 6:48 am

Hi Antti, thanks for stopping by. I have an article on using .htaccess to compress your files here. .htaccess is suppose to compress a little better on paper, but in practice I really see no difference between compressing with .htaccess and PHP.

In fact, I like PHP because more people can use it and it’s also much easier to test to see if it’s working.

BTW, I tried commenting on your blog and the posting of comments seems to be not working. Ironically, I was commenting on the .htaccess tricks post you have and was mentioning how #4 broke my comment section a while back when I tried it. If you’re using that code, you might try disabling it and seeing if your comment section fixes itself.


Richard Neuman November 19, 2009 at 1:17 pm

Great Tip!
Do you know if using this method with interfere with using the Super Cache Plugin, or if either with negate the effects of the other?


John Hoff November 19, 2009 at 4:21 pm

Hi Richard. I use the WP Super Cache plugin and as you can see from the screen shots above it doesn’t interfere with compression.

The two work well together.


Deb Phillips | Lewisville Photos December 5, 2009 at 8:34 am

Greetings, thanks for providing the info in this post. I’m looking into implementing gzip compression on my site, because Google’s Webmaster Tools Site Performance tool recommends applying gzip compression to the Google Analytics ga.js code on my site. I assume your PHP solution will successfully compress the ga.js code, as well as all other compressible page components?

Another question I have: By implementing your PHP gzip solution, do I need to be concerned about it perhaps not working properly with older browsers, such as IE 6?

I’m far from being an expert in PHP and in modifying .htaccess files, so I appreciate your sharing your knowledge on gzip compression. Thanks very much.


John Hoff December 5, 2009 at 10:03 am

Hi Deb.

Yes it does provide the compression, however, there are concerns with earlier web browsers. IE5 probably won’t be able to display your site. IE6 with sp1 won’t either, but users of IE6 with sp2 (service pack 2) should be able to.

So if you want to accommodate for those earlier browsers, you probably won’t want to use gzip.


Deb Phillips | Lewisville Photos December 5, 2009 at 10:45 am

Thank you for your response, John. That’s helpful.

It’s excruciating for me to think I might be preventing even one visitor from accessing my site! In reviewing my stats, I see that IE 5 visitors account for less than 1% of my visitors for this year-to-date, and IE 6 visitors account for 24% of visitors. (I wish I could tell how many IE6 visitors were SP2.)

I realize I may need to hold a bigger perspective regarding my site’s efficiency. I’d be curious to know the perspective of other web masters when deciding whether to implement changes that may preclude or hamper older browsers, such as IE5 and some IE 6 visitors.


Micah December 16, 2009 at 9:12 pm

Hey John, I wanted to let you know that there’s a new Trac ticket for Gzip compression.

The option for Gzip should be included in Wordpress as it already is for other major CMSes and blogging platforms. Thus, I hope in the next versions we can get support to include an option to turn it on preferably using the mod_deflate module but of course supporting other methods like ob_gzhandler if the developer chooses this is the best method.

Please spread the word so we can make this a reality by verion 3.0!


John Hoff December 18, 2009 at 4:56 am

That would be an awesome feature, Micah, especially since Google’s going to be paying more attention to the load times of our sites.

I would definitely suggest they provide support for the various types of compression out there. Some web hosts allow for one type while others don’t allow for others. It would be good to be able to accommodate as many people as possible.


Keith Davis December 20, 2009 at 10:37 am

Hi John
I read this post when it first came out and whilst it was interesting, I didn’t think too much about it.

Tonight I’ve just checked my sites using Google Webmaster Tools and noticed that it now has a section for “page load times” – perhaps I’d just missed it in the past.
So I checked my sites… all my html sites are super quick but my single Wordpress site is super slow.
So I’m back to this post.

I’m sure that I read somewhere that “page load time” is now one of the metrics that Google uses to allocate Google Pagerank, so I have to speed up the site.

Hard to believe that such a small piece of code can make all that difference but if your site was four times faster, I’m prepared to give it a go.
I’ll let you know what my figures are.
.-= Keith Davis´s last blog ..The eyes have it! =-.


John Hoff December 20, 2009 at 11:10 am

Hi Keith. Keep in mind that this compression method could make users of IE6 and below have a hard time seeing your site.

I checked my analytics and I have a very small percentage of people who come to my blog using IE6, so I’m using the compression.

Another thing you can do to speed up your blog is use the WP Super Cache plugin. It’s a monstrous plugin and some people don’t like it, but most do. It’ll speed things up quite a bit. I use it.
.-= John Hoff´s last blog ..How To Backup Your WordPress Blog’s Database With A Plugin =-.


Keith Davis December 20, 2009 at 11:23 am

Thanks John
I didn’t realise that it caused problems in IE6.
Thought it was too good to be true… might have to rethink that one.
What does “monstrous” mean in relation to the WP Super Cache plugin?
.-= Keith Davis´s last blog ..The eyes have it! =-.


John Hoff December 20, 2009 at 11:33 am

It adds code to your .htaccess file (and I’m not sure where else) and basically serves up your posts and pages as .html files. I’m not sure what all changes it makes, but I know that whatever it does, deleting the plugin is not standard. You have to do a few steps to completely delete it.

I wouldn’t worry about it too much, you can try it with no problems, most everyone does.


Deb December 30, 2009 at 1:19 am

I tried this trick twice and it isn’t working. My blog is hosted at Hostgator and it uses php not sure why it isn’t working. I wanted to try this before installing wp-cach or super cach because I have had those plugins in other blogs and they can botch things up. I’m no pro at coding but I did install this and update twice, nothing.
.-= Deb´s last blog ..My Toshiba Satellite Explodes =-.


John Hoff December 30, 2009 at 9:29 am

Hi Deb. It could be an issue with your web host. Brad (another commentator above) had a similar issue because the compression wasn’t compatible with his web host. The work around is to use zlib compression.

He wrote an article on how he got his to work here.


Keith Davis January 1, 2010 at 6:24 am

Hi John
I’ve read the Brad Ney article and will give his zlib method a try.
Brad thinks that the zlib compression should be OK with IE6.

I’ll make sure that IE6 is behaving, check the speed using the “port80″ software and report back the results.
.-= Keith Davis´s last blog ..Ooh la la… =-.


John Hoff January 1, 2010 at 12:05 pm

Yeah let me know about IE6.

gzip is compatible with IE6 service pack 2, but anything earlier it is not. I thought zlib would cause the same issues though, but let me know.
.-= John Hoff ´s last blog ..Aside From A Blogger, What Are You Really? =-.


Rockstar Sid January 13, 2010 at 9:25 pm


There is a feature known as ‘Super cache compression’ in wp-super-cache which I have enabled as the code you have mentioned didn’t quite work out because of the theme which is quite complicated.

Can you let me know if this is the right thing to do? It shows as compressed :)
.-= Rockstar Sid´s last blog ..Another Free Maxim Magazine Subscription For 2010 =-.


John Hoff January 13, 2010 at 9:47 pm

Hey Sid. Just checked your site and you’re compressed and ready to go.

The WP Super Cache compression uses gzip through .htaccess and is definitely another way of doing it.

So you’re all good.


Keith Davis January 23, 2010 at 11:45 am

Hi John
Still looking at speeding up via gzip.
Looking at my Google Webmaster diagnostics, I notice that google recommends using gzip so I’m going to give it a go.

Quick question…

The method you demo in the video uses code in the header.php, “WP Super Cache compression uses gzip through .htaccess” and I have spotted a few posts out there on adding code to .htaccess in order to activate gzip.

Is one method superior to the other, or is it simply a case of you pays your money….?
.-= Keith Davis´s last blog ..Ooh la la… =-.


John Hoff January 23, 2010 at 3:50 pm

Hey Keith. There’s not much of a speed difference that I’ve seen between compression using PHP vs. .htaccess.

In general, .htaccess is a better way of doing things since it’s read even before Google starts loading your site. The PHP way might be a little easier to implement because it’s just a line or two of code to copy/paste whereas the .htaccess code is a little more complex.

I’d say enable the compression through the WP Super Cache plugin and go ahead and use the PHP one as well… it’s what I do.
.-= John Hoff´s last blog ..How To Create A Category In WordPress =-.


Keith Davis January 24, 2010 at 2:42 am

Thanks John

I’ll give the “PHP in header” method a try today and check out the site in IE 6!

The “Port 8o” software is a great visual way to see those file reductions and it’s telling me that I can make some big savings.
.-= Keith Davis´s last blog ..Ooh la la… =-.


SchoolPaper Addict March 14, 2010 at 2:08 am

Hello, do you know how I can apply this to my new blog? I opened up an account in blogspot.com. Thank you John.
.-= SchoolPaper Addict´s last blog ..Somebody Hates Schoolwork – School Papers Suck =-.


John Hoff March 14, 2010 at 8:50 am

No, I don’t think you can use this technique for a free hosted blog on Blogger, but try this search here for some tips on doing something like it.


silicon April 11, 2010 at 1:37 pm

I had to edit php.ini to zlib.output_compression = On before this would work. My webhost had it off by default. Thanks!


Keith Davis May 10, 2010 at 10:22 am

Hi John
Came across an article post which talked about speeding up Wordpress sites and it reminded me of this article.

Article is located at:

The WP-Super-Cache plugin is mentioned plus it points out that a future version of this plugin will allow Googlebot to record a faster load speed for a site.

I don’t know how busy you are these days John… you being an Ebook millionaire and all LOL… but if you are looking for a video topic, how about installing and configuring WP-Super-Cache plugin.

Yours in hope.
.-= Keith Davis´s last blog ..Flying in formation =-.


John Hoff May 10, 2010 at 10:48 am

Hey Keith. Thanks for the link and I’ll check that out now.

I’ll put the WP-Super Cache video on my to-do list. I think that would be a good one.

By the way, nice to hear from you again. I’ve been on a little break (as I’m sure you’ve noticed) from blogging, but I’m back (been on Twitter and email, though). Hope all has been well with you.


Keith Davis May 10, 2010 at 11:33 am

I had noticed your absence.
Good to have you back.
.-= Keith Davis´s last blog ..Flying in formation =-.


Yash May 20, 2010 at 11:27 pm

What should i do, if i am running .html


John Hoff May 24, 2010 at 10:15 am

Good question and that’s a full post on its own.

1. Put your javascript codes down at the bottom (just above the ending /body tag). This means your content and other images will load and be displayed first and then the slower javascript will load.

2. Usually not necessary, but if you’re looking to squeeze every bit of speed out of your site, you can compress any of your external css files. What that does is remove all spacing between lines and effectively makes your css file one line of code. Google css compressor or something and you’ll find an online tool for that. Just remember though, when you do that your css file will not be well written for editing. Make sure to keep a copy of the uncompressed version and use that to make changes. When your changes are done, create a compressed version and upload it to your site.

3. You can use .htaccess to compress statics sites. Check out this tutorial here.

4. Make sure your images are compressed. For example, image.gif could be twice as big as image.jpg is. Be sure to convert and optimize images (something I need to be better about).


Aaron June 26, 2010 at 3:06 pm

Hey John.. I’ve found a plugin called W3 Total Cache that has helped me MASSIVELY increase loading times by using compression, page caching, and database caching. I had never heard of it before I tried it.. always heard of WP Super Cache, but i find W3TC to work much better, it has memcached and CDN support, and just an overall great plugin. It might be worth mentioning in a future update to this blog post and compare the caching/compression plugins that exist out there.


John Hoff June 26, 2010 at 3:13 pm

Hi Aaron, yeah I’ve heard of that plugin as well and I tested once a while back but I think it conflicted with another plugin or something else that I was doing, so I stuck with the WP Super Cache.

The W3TC plugin looks to work really well. Thanks for the input.


Jamie of Dumpster Rental Ma September 13, 2010 at 9:56 am

Thanks for this blog post. This topic is what I really need for all my blog’s loading time. Hopefully when I visit here again would I witness other new things.


mark November 15, 2010 at 11:49 pm

I also got good results with W3 Total Cache, everything else I tried just gave me 500 errors.
I am now installing it everywhere :)


bjantiques@low cost hosting February 24, 2011 at 5:26 am

i places the code as described however when i go to the port80 web site and test the site it tellsme is is not compressed. Whats up?



John Hoff February 26, 2011 at 8:51 am

Hi BJ.

Some hosts don’t like gzip, but rather zlib for compression. Check out one of the older comments by Brad Ney. He wrote a post on using zlib after figuring out gzip didn’t work for his host.


bjantiques@low cost hosting February 26, 2011 at 12:36 pm

Ok all resolved I was certain that we had it gzip activated and so Found a test file that we knew was working and would show if it was the server or not. That file worked. So copied the command line from that file and replaced the one i got here then mine worked however I was now getting an object open error. To stop this I had to take the line out of the header and put the line of code into the blogs primary index.php not the header that way you do not get errors from the else ob_start command.



wpdotmd August 13, 2011 at 1:06 am

There are a GzipDetect online tool to check if GZip is enabled:


Slon April 22, 2013 at 9:35 pm

Thank YOU Man!!!! Appreciate it!!! Slow website was a real problem for me .
You made me really happy !!! God Bless You!!!

Would be also nice if you know any other ways to make it faster!

Thanks again,


Leave a Comment

{ 1 trackback }

Previous post:

Next post: