Search
Close this search box.

Speed Up Your Site With GZIP Compression

[updated_on]
Share this post:

HTTP Compression Test

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png

Slow WordPress sites are bad for business. Luckily, optimizing them is easier than you think. Using GZIP compression requires minimum effort and can be effective in speeding up some WordPress sites.

Enabling GZIP is done by simply adding a small amount of code into your site’s .htaccess file. Enabling it shouldn’t take more than 5 minutes of your time.

Your site may already be compressed using GZIP compression or another compression technology. So first we’re going to run a text to find out.

You can either watch the detailed video tutorial below or scroll below that to read the image/text version of the tutorial.

HTTP Compression Test

First of all, check whether your WordPress needs optimization. Go to this page: http://www.whatsmyip.org/http-compression-test/.

Enter the domain name

To begin the test, make sure you enter the URL of your page inside the box as seen on the screenshot.

Click on the test button and see whether your site is already optimized or it needs compression.

If your page is not compressed, you will see a message in red saying your site is NOT Compressed:

If there’s a big difference between the current page size and the possible compressed page size, then compression can improve your site speed.

Let’s get to it.

Enable GZIP Compression

Enabling Gzip compression is really easy using these step-by-step instructions:

  • Go to your Cpanel and click on ‘File manager’ – There might be a popup where you need to check the ‘show hidden files checkbox’. If this isn’t the case, go to Settings in the upper-right corner once inside the file manager and check it manually.
  • Navigate to the root of your website

  • Find the htaccess file – If you’ve followed the steps above (e.g. checked the show hidden files box) and can’t find the htaccess file you can create a new one. To do that go to the file menu and create a new file called .htaccess. Missing the htaccess file is highly unlikely if you already have WordPress installed because WordPress creates the .htaccess file automatically for its permalinks.
  • Click on the .htaccess file to highlight it.
  • Then click on ‘Code Editor’ and then on Edit.
  • In the ‘Code Editor’ you may see some WordPress code, don’t touch it.
  • Copy and paste the code below into your .htaccess file.  Make sure not to disturb any of the existing .htaccess code if there is any.
  • Click on Save Changes” and you’re good to go.

Gzip Compression code for .htaccess file

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png

After copying the code, your .htaccess file should now look similar to the one on the screenshot below.

Testing the compression

Assuming you’ve followed the instructions, your website should now be compressed. You can check the results of your work by repeating the first and second step on the HTTP compression test website.

Go back to the HTTP compression test website and enter the domain name into the bar for testing. Click on Test to see if the compression works.

If you encounter any unexpected errors and gzip compression doesn’t do the trick, you can try the mod_deflate compression explained in this blog post and video over here. If that fails to work as well, leave a comment below and we’ll find a way to speed up your site.

For customizing your WordPress site further, make sure you subscribe to my WordPress Tutorials – WPLearningLab channel and click on the bell notification not to miss any of the useful WordPress tutorials.

Share this post:

9 thoughts on “Speed Up Your Site With GZIP Compression”

  1. Hi Sir, When I tried to insert the link of my website in that test it is showing me “Error – Unable To Load URL”

    How can we fix that please help?

  2. Hi Bjorn,

    I tried your method of adding the Gzip Compression code to the .htaccess file.
    But unfortunately, it has not worked.
    Can you advise me of another way to implement Gzip on my site?

    Thanks I n Advance
    John

  3. Thanks so much , I tried this is method and It increase my website speed test , but for desktop only , and doesn’t effects on mobile speed test, Why & how increase speed score test for my website for mobile ?

    1. Hi Fatema,

      The speed test should tell you want you need to do to speed your site up in mobile. Have you tried the GTMetrix.com speed these to see what is slowing your site down?

  4. Hi! I have executed as in the tutorial yet no change when I run the website through a page speed tool (like google page insights or gtmetrix). I have mod_deflate.c code pasted in the .htaccess file as well.

    On the report from GtMetrix I see the files that has to be compressed come purely from facebook.

    screen shot here > https://snag.gy/ePEOIJ.jpg

    What else I can do?
    PS: have posted this question below the YT video as well.

    Thank you

Leave a Comment

Your email address will not be published. Required fields are marked *

WPLearningLab