How to Enable Compression in WordPress: The 110% Guide to GZIP Compression

Become a WordPress Buff
Share on twitter
Share on email
Share on facebook
Share on linkedin

As Google becomes increasingly concerned with websites’ User Experience (UX), optimizing your site for the platform’s top ranking signals is critical. Among the most important factors to pay attention to are page speed and loading times.

One of the fastest and easiest ways to improve site speed and performance is to enable compression in WordPress. There’s a possibility that your web host automatically enables GZIP compression for you. If not, there are also ways you can take care of this crucial task yourself.

Enable compression WordPress.

In this post, we’ll explain what GZIP compression is and how it works. Then we’ll discuss how to check and see whether GZIP compression is functioning on your site, and if not, the three methods you can use to enable compression on WordPress. Let’s get started!

In This Article✍️

Our team at WP Buffs helps website owners, agency partners, and freelancer partners enable GZIP compression and monitor their WordPress sites 24/7. Whether you need us to manage one website or support 1,000 client sites, we’ve got your back.

What Is GZIP Compression? 🗜️

GZIP is a file format and a software application used for file compression and decompression. It was created by Jean-loup Gailly and Mark Adler, and released as a free software replacement for the compression program used in early Unix systems.

As with the Core WordPress software, GZIP was intended for use with GNU (open-source free software). The “G” in “GZIP” is from “GNU”.

GZIP compression does not work on images, and it is a mixed bag when it comes to media files. For example, some image files like MPEGs and WAVs compress well with GZIP. Other file types, such as MP3s, may actually increase in size if you try to compress them.

It’s also important to note that GZIP compression must be enabled on your web server before you can enable file and folder compression. In a bit, we’ll discuss how to determine whether your web server has GZIP enabled.

On the client side, all modern web browsers support GZIP compression, and automatically ask for it when making HTTP requests. This means that you can expect all users to reap the benefits of GZIP compression once you’ve enabled it.

Why Does GZIP Compression Matter?🤷

Compression is commonly encountered in the computer world. Put simply, it is a very handy method of grouping a lot of files together into one smaller file. This helps alleviate some of the issues that arise from having too many large files on your site, which can slow down the loading times of your web pages.

This matters because a slow-loading website can negatively impact UX and impede conversions. In fact, according to Neil Patel, 47 percent of consumers expect a web page to load in two seconds or less. If you’re running an e-commerce business, up to 79 percent of customers say they’re less likely to buy from a website if it provides a poor experience.

Web pages can take up a lot of server space due to large file sizes, especially render-blocking JavaScript files (or JavaScript W3). This is why you should compress JavaScript files of these types as much as possible.

Fortunately, there are plenty of tools that can help you diagnose page loading issues, including Google Pagespeed Insights, GTmetrix, and Pingdom. Once you’ve uncovered a performance problem, you can take action to resolve it.

Also, if you need help with JavaScript specifically, Zac Gordon provides a series of excellent JavaScript for WP courses. You can use them to learn the popular programming language both on its own and alongside WordPress.

How Does Compression Work in WordPress? 🧐

A mashup of computer languages – HTML, CSS, and JavaScript – is used by almost all modern websites. If you reduce them to their most basic form, you’ll find that websites are essentially text files. This means there are various ways you can optimize your site’s data.

For example, minification is one technique often used to enable text compression in WordPress. You can also compress components with GZIP WordPress compression, which is the equivalent of file compression for websites. It is the process of reducing your website’s file sizes (including HTML, JavaScript, and CSS files).

When users go to your website, their browsers download these text files, and will begin rendering the website according to the code contained within them. That code is then translated to something readable and understandable to human users.

However, browsers don’t require all the extra white space and extra formatting used to improve readability for humans. As long as the browser can analyze the code’s content, it can be written in one long block of text.

Therefore, WordPress GZIP compression takes away the formatting that is mainly used for human understanding. Reducing the length of the code in this way also reduces the size of the file containing it.

WordPress GZIP compression can do wonders for your website’s performance, especially when it comes to improving page loading times. If you have ever searched “how to gzip a file”, then this is the article for you.

How to Determine Whether GZIP Compression Is Enabled in WordPress 🧪

Your web host might enable compression in WordPress by default during the account setup process. However, this isn’t always the case. You can check to see if you already have GZIP compression enabled in a couple of different ways.

One of the fastest and easiest methods is to use an online checker such as Base64.Guru’s Gzip Test:

The process to check for GZIP compression is pretty similar regardless of which GZIP test tool you select. All you have to do is provide the URL for your website, and then run the search:

The response HTTP headers from testing whether GZIP is enabled.

The tool will respond in one of two ways:

  1. It will tell you that your site is GZIP-enabled, and show you how much space was saved via compression.
  2. It will tell you that you do not have GZIP enabled.

You can also check to see if your browser receives the content-encoding: GZIP header in the response from the web server. If you’re using Chrome, open your site in a browser tab, then right-click anywhere on the page and select Inspect to open the developer tools.

Next, navigate to Network and click on the home page name. Select the Headers tab, and then scroll down to find the Response Headers section:

The content-encoding GZIP compression response header in Dev Tools.

There, you’ll see whether or not GZIP compression is enabled.

It’s worth emphasizing that GZIP compression is actually something that you need to enable on the server side, not in WordPress. When you host with companies like GoDaddy or Kinsta, they’ll have this feature already enabled as a part of their standard hosting packages. For some of the other web hosts out there, it’s up to you to enable WordPress GZIP compression.

How to Enable GZIP Compression in WordPress (3 Methods) 🏁

If you’ve determined that WordPress GZIP compression is not yet enabled, there are multiple methods you can use to get it running. Below, we will cover the options for enabling GZIP compression in WordPress, including methods for experienced back-end web developers and newbie WordPress users alike.

1. Enable WordPress GZIP Compression by Manually Editing Your .htaccess File

One of the most common ways to enable WordPress GZIP compression is to edit your .htaccess file. However, this particular method involves modifying your site’s code, which comes with the risk of breaking something. This is a sensitive server file, and one wrong move could cause a lot of problems.

To reduce the likelihood of harming your WordPress website, be sure to save a copy of the original file before making any changes. Also, remember to back up your WordPress website! Once you’ve covered these bases, it’s time to get to work.

The .htaccess file should be in the root folder of your website. The best way to access this file is through a File Transfer Protocol (FTP) client. Once you locate this file, you can either edit it directly or download it to your computer before making changes.

After you locate and open .htaccess, add the following code below the sections marked by the # BEGIN WordPress and # END WordPress tags (beyond this, the specific location where you include the snippet doesn’t matter):

# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Save the file and upload it to your site’s server. When you’re done, run your website through a GZIP compression checker tool (or verify the response headers) as discussed earlier, to make sure you were successful.

Enable GZIP Compression in NGINX or IIS

While most shared hosting plans run on Apache web servers, you may be using something else, such as NGINX or Microsoft’s IIS. Enabling GZIP compression for NGINX web servers is slightly different from the process outlined above.

If you’re running on NGINX (for example, if you’re a Kinsta user), you can enable GZIP compression in WordPress by opening your nginx.conf file and adding the following code:

gzip on;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;
gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/javascript application/x-javascript;

If you are running Microsoft’s IIS, please see Microsoft’s documentation on how to enable GZIP compression in WordPress.

2. Enable GZIP Compression in WordPress By Contacting Your Hosting Provider

Many web hosts enable WordPress GZIP compression by default, since it offers such noticeable performance benefits. Others, such as SiteGround, only provide their own instructions for enabling WordPress GZIP compression.

If you do not have GZIP compression enabled by default, and you’re not comfortable making changes to your website’s files, you can ask your web host to enable WordPress GZIP compression for you. In general, most web hosts will be willing to assist you with this query when you reach out to their customer support teams.

3. Enable GZIP Compression in WordPress via a Plugin

Of course, if you’re using WordPress, there’s always a plugin that can make the job easier. The caveat? More plugins means more potential security vulnerabilities, and they take up some space on your server.

Regardless, there are a handful of helpful tools that let you easily enable WordPress GZIP compression, including:

WP Rocket

WP Rocket is a caching plugin that helps WordPress sites load faster in just a few clicks. Upon activation, WP Rocket adds GZIP compression rules to your .htaccess file, using the mod_deflate module. This is a powerful premium plugin, with plans starting at $49 for a single site license.

WP Super Cache

The WP Super Cache WordPress plugin.

WP Super Cache is another WordPress caching plugin that offers the option to compress code. It is free to download and use.

To enable WordPress GZIP compression using WP Super Cache, first install and activate the plugin. Then navigate to WP Super Cache > Advanced in your dashboard, and check the box labeled Compress pages so they’re served more quickly to visitors.

W3 Total Cache

The W3 Total Cache WordPress plugin website.

W3 Total Cache is considered to be one of the best WordPress caching plugins. It is a robust tool that serves many purposes, including enabling compression.

A note of warning: WordPress newbies can easily break their websites when using W3 Total Cache without proper configuration. However, if you know what you’re doing, you can enable HTTP compression with this plugin by going to the browser cache option and checking the box for HTTP compression.

Enable Gzip Compression

The Enable Gzip Compression WordPress plugin.

Many of the tools that let you enable GZIP compression on your WordPress site are caching suites designed to optimize performance. Compressing HTML, JavaScript, and CSS files are proven ways to improve your site’s speeds.

In contrast, Enable Gzip Compression does only one thing – it helps you enable and disable GZIP compression for your WordPress site if you are using an Apache web server. It’s a free plugin, although there’s a premium version with broader functionality.

PageSpeed Ninja

The PageSpeed Ninja WordPress plugin.

PageSpeed Ninja is a full WordPress performance plugin that you can download for free. One of its features helps you easily enable GZIP compression in WordPress.

To do so, first install and activate the plugin. Then you can navigate to Settings > PageSpeed Ninja > Advanced, and toggle the setting next to Enable compression.

Frequently Asked Questions🤔

Some hosting providers automatically enable compression in WordPress. To see whether compression is enabled on your WordPress site, you can use an online tool such as Base64.Guru’s Gzip Test, or manually search the response headers in Chrome DevTools.

However, if you find that GZIP compression in WordPress is not enabled, there are a few options at your disposal. You can add code to your site’s .htaccess file to manually enable it, reach out to your hosting provider to ask for help, or install a plugin such as WP Rocket or Enable Gzip Compression.

Wrapping Up🎁

While there are plenty of ways to improve your WordPress site’s speed and UX, GZIP compression is one of the quickest and easiest options. Some hosting providers enable this feature automatically. However, if you see that GZIP compression isn’t active on your WordPress site, you have a few choices.

As we discussed in this post, the three main methods you can use to enable compression on WordPress are:

  1. Manually edit your site’s .htaccess file to add a few snippets of code.
  2. Contact your hosting provider to have them enable it, which is recommended if you aren’t comfortable working with code.
  3. Install a WordPress plugin to enable GZIP compression, such as WP Rocket, PageSpeed Ninja, or Enable Gzip Compression.

Once you’re done, there are several additional tactics you can employ to improve page speeds, such as leveraging image optimization plugins and using a CDN. If you need help with your optimization efforts, just reach out to us here at WP Buffs. We have several Care Plans that suit the needs of website owners, developers, and businesses!

Want to give your feedback or join the conversation? Add your comments 🐦 on Twitter.

Share this post:
Share on twitter
Share on email
Share on facebook
Share on linkedin
Did you enjoy this post? Subscribe for more
No thanks. I can manage, speed up, secure, fix and grow websites myself.

Schedule a private call with our team to discuss our 24/7 WordPress care plans for serious website owners or 24/7 white-label site management for agencies and freelancers

Register for our next live WP AMA event!

🏆Chance to win weekly giveaways

📆 Instant invites to our Weekly WP AMA

🙋 First access to submit questions

💻 Direct links to all of our events

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy. By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.

Read about how we increased Rigorous Digital's profit margin by 23% and helped remove all website issues for MEP Publishers and their 3 complex websites.

Case study eBook cover (MEP Publishing)
No thanks, I don't need more profit and I can tackle all my WordPress issues myself.
Case study eBook cover (Rigorous Digital)

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

 

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy.

By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.

Which care plans best fit your websites (or client sites)?

✔️ White-label site management

✔️ $1,000+ of premium plugins free under our care plans
✔️ 24/7 website edits and priority support
✔️ Ongoing speed and security optimization
✔️ 24/7 website uptime monitoring
✔️ 4x daily cloud backups
✔️ Weekly plugin, theme and core file updates
✔️ Weekly reports detailing any on-site changes

No thanks. I can manage, speed up, secure, fix and grow websites myself.
Questionnaire

Finally, a WordPress newsletter you'll actually read every single month.

✔️ High-impact news

✔️ Actionable tutorials and videos

✔️ #WordPress Twitter highlights

✔️ Vote on receipient of $200 donation and WP Buffs merch giveaways

✔️ Fully curated so you only receive the best 5% of content

No thanks, I have other ways to stay updated with WP

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy. By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.

Finally, get your website 99.9999% secure and loading in under 1 second.

Our free eBooks and easy-to-follow checklists will have your website fully optimized in just a few hours.

No thanks, my website is as fast and secure as I want it.

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy. By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.

How to Sell Your Very First Care Plans Cover

Finally, an email list that helps make WordPress simple and effective for you.

Speed & security optimization tips and detailed how-to guides with advice you can implement today.

No thanks, I already know everything about WordPress.
Speed checklist eBook cover

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

 

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy. By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.

Case study eBook cover (Rigorous Digital)
Case study eBook cover (MEP Publishing)
How to Sell Your Very First Care Plans Cover

Honed and proven strategies we've used successfully 500+ times to help you sell your first care plans. Action steps you can implement in minutes.

No thanks, I can already sell as many care plans as I want.
How to Sell Your Very First Care Plans Cover

WP Buffs, LLC is committed to protecting and respecting your privacy, and we’ll only use your personal information to administer your account and to provide the products and services you requested from us. From time to time, we would like to contact you about our products and services, as well as other content that may be of interest to you. If you consent to us contacting you for this purpose, please enter your name and email address above.

 

You can unsubscribe from these communications at any time. For more information on how to unsubscribe, our privacy practices, and how we are committed to protecting and respecting your privacy, please review our Privacy Policy.

By clicking submit above, you consent to allow WP Buffs, LLC to store and process the personal information submitted above to provide you the content requested.