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 server. 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


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.

scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

2 thoughts on “How To Enable GZIP Compression In WordPress Without A Plugin”

  1. 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?


    • 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