How to compressed content of WordPress without using gzip!

Filed Under (Tips & Tricks) by admin on 05-08-2010

Tagged Under : ,

WordPress Compressed

WordPress Compressed

We all know that WordPress is one of the most popular CMS for blogging. It’s user friendly UI and  safety make  it accepted in mass.

I just want to increase download speed of my blog. So, I used some Plugin of to do so. It did but not to my satisfaction. Moreover, I did not have GZIP facilite in my server, so I need to take other way.  I log into my server thruough FTP software and  opened index.php file of my blog and add following PHp code at top of the page.

==========CODE ============

ob_start(‘ob_gzhandler’);
==========================
It compressed content sent from the server to the client.

Wait, it is not done yet. What about CSS files?

We need to compress them too. Here are the steps that you need to do:

  • Open all the CSS files and put following codes in top and buttom of the file.
  • Save the file with add “.php” extension. For example, earlier style1.css later style1.css.php.
  • Add “.php” extenstion to the template page of Template that you are using.
  • ========== CODE - TOP ============

    <?php if(extension_loaded(‘zlib’)){ob_start(‘ob_gzhandler’);} header(“Content-type: text/css”); ?>
    ==========================

    ========== CODE - BUTTOM ============

    <?php if(extension_loaded(‘zlib’)){ob_end_flush();}?>
    ==========================

    Hope you will find it usefull and please do share your knowledge to make it better.