How To Enable GZIP Compression In WordPress Without A Plugin

Home » WordPress Tutorials » How To Enable GZIP Compression In WordPress Without A Plugin
  • enable gzip compression

How To Enable GZIP Compression In WordPress Without A Plugin

Enabling GZIP Compression is one of the easiest things you can add to your website to greatly reduce the load time for your users. You can easily enable GZIP compression with a plugin, but that is a hassle and adds unnecessary bulk to your website. A better option is to enable GZIP compression with a few lines of code to your .htaccess file.

If you are on a decent host, most of them come with GZIP compression already enabled on the sever. If you are looking to change your host, I recommend Siteground. (But, if you need to know how to enable it on your server, that is for another post coming soon!)

Step 1 Access .htacess file

To begin you will need to use one of the following:

  • CPANEL file manager
  • File Transfer Protocol (FTP)
  • Tools Section of Yoast SEO

The tools section of Yoast SEO gives you the ability to modify your .htacess file. This makes it easier to modify it because you will not need to leave your WordPress admin panel.

Step 2: Enable GZIP Compression

I am going to assume that there are other lines and code in your .htaccess file, so you will want to add this at the very top of the file.

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript 
application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml 
text/plain text/xsd text/xsl text/xml

</IfModule>

The good news is if you add this and mod_deflate is not installed it will not crash your website. Additionally, this code will GZIP .SVG files. We do not GZIP every file type because doing this with media files is ultimately a waste of server resources. Lastly, if you’re using .swf files, often times GZIP will break pre-loaders by making them appear broken on your website.

By |2018-02-12T14:51:00+00:00February 12th, 2018|Categories: WordPress Tutorials|Tags: |2 Comments

About the Author:

Scott Hartley is a WordPress Developer who focuses on website performance optimization, SEO, and security. He can't tell you what a color wheel is but he knows the intricacies of making a website load quickly.

2 Comments

  1. Rob Rowland May 2, 2018 at 6:38 pm - Reply

    Hi Scott,

    Thanks for the article.

    I couldn’t quite understand your last sentence.

    Does the use of the code listed “break” .swf files? or can it be used on sites with .swf content?

    Thanks,
    Rob.

    • Scott Hartley May 2, 2018 at 8:17 pm - Reply

      I can see the confusion in that last statement no the above code does not break .swf files because it does not compress them I will have the article updated to clarify.

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.