Enable GZIP Compression in WordPress: The 110% Guide

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

As Google becomes increasingly concerned with website user experience, web developers are rushing to become compliant.

After all, a major user experience factor, page speed and loading time have become a major search ranking factor as of July 2018. We are now well beyond that, it’s time to stay updated, WordPress friends!

Yes, we’re implying there will be implications on search engine results pages (SERPs)!

To that end, we will cover one of the fastest and easiest ways to improve performance by showing you how to enable GZIP compression in WordPress.

🤐 It's 2020 all, it's time to zip it up! GZIP compression, that is. #WordPress. Click To Tweet

WordPress Tutorial Guide: GZIP Compression ✍️

What is WordPress GZIP Compression? 🗜️

GZIP is a file format and a software application used for file compression and decompression.

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

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

WordPress GZIP compression is the process of reducing the size of your website files, including HTML, JavaScript, and CSS.

enable gzip compression wordpress

GZIP compression does not work on images, however, and it is a mixed bag when it comes to media files.

For example, some images files, such as MPEG and WAV files, compress well with GZIP, while other file types, such as MP3 files may actually increase in size if you try to compress them.

GZIP compression must be enabled on your web server in order for it to work you to enable file and folder compression (web servers with GZIP enabled will return the content-encoding: GZIP header in its response).

From 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 GZIP Compression Matters 🤷

Besides implications for search, the negative impact of a slow loading website to the user experience can also impede conversions.

According to Neil Patel, 47% of consumers expect a web page to load in 2 seconds or less. If you’re running an e-commerce business, Kissmetrics again reports that up to 79% of customers say they’re less likely to buy from the website, due to dissatisfaction with the user experience.

Web pages can take a lot of server space due to large file sizes, especially render-blocking JavaScript files (or JavaScript W3) — you should compress JavaScript files of these type as much as possible. Although you might not notice the impact of these large files (and resulting slow page load times) have, there are plenty of tools that can help you diagnose page load issues:

If you’ve uncovered a page load issue, it’s time to take action.

If you would like help with JavaScript, we know a guy. Zac Gordon absolutely crushes it in his JavaScript for WP courses. Learn the popular programming language, JavaScript, both on its own and alongside WordPress.

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 1 website or support 1000 client sites, we’ve got your back.

Compression is commonly encountered in the computer world. Put simply, It is a very handy method of grouping a bunch of files into a smaller file.

For websites, WordPress GZIP compression is the equivalent of file compression. And it can do wonders for your website’s performance—especially when it comes to improving page load time. If you have ever searched “how to gzip a file”, this is the article for you.

How Does WordPress GZIP Compression Work? 🧐

A mashup of computer languages—HTML, CSS, and JavaScript—are used by almost all modern websites. Reducing them to their most basic form, they’re essentially text 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 these files. These codes are then translated to something readable and understandable to the average human.

⌨️ Clean, semantic code is the gold standard for human operators looking to modify over time, especially if you want to enable GZIP compression in #WordPress. Click To Tweet

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

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

GZIP Test to Check if Compression is Enabled in WordPress 🧪

Before you proceed further, you can check to see if you already have GZIP compression enabled (for example, your web host might enable it by default during the account setup process).

One of the fastest and easiest ways of doing so is to use an online checker (such as Base64 Guru’s GZIP Test).

gzip test

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

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

gzip test

You can also check to see if your browser receives the content-encoding: GZIP header in the response it receives from the web server.

If you’re using Chrome, go to Developer Tools > Network, then click on the homepage name. Scroll down in the information that appears to find the Response Headers section.

gzip test

How to Enable WordPress GZIP Compression 🏁

WordPress GZIP compression is actually something that you need to enable on the server side—not WordPress. When you host with companies like GoDaddy or Kinsta, they have this already enabled as part of their standard hosting packages.

For some of the other web hosts, it’s up to you to enable WordPress GZIP compression.

If you’ve determined that WordPress GZIP compression is not yet enabled, there are multiple methods to get started— we will cover several methods on how to enable GZIP compression in WordPress, including options for experienced backend web development and newbie WordPress users, alike.

1. Enable GZIP Compression: The WordPress Definition

Enabling GZIP compression for your WordPress site by editing your .htaccess file This is the most common way to enable WordPress GZIP compression.

This is the most common way to enable WordPress GZIP compression.

However, this particular method involves the possibility that you might break something. After all, .htaccess is a very sensitive server file, and one wrong move can mess up your whole website.

Enable GZIP Compression

To reduce the likelihood of breaking your WordPress website, be sure to make a copy of the original file before making any changes. And back up your WordPress website!

Once you’ve covered all your bases, it’s time to get rolling.

The .htaccess file should be in the root folder of your website. This file, however, is usually hidden by default on both the remote server and your own machine, if you copy it.

The best way is to access the file is through FTP. Alternatively, you can use another admin interface or cPanel.

To enable WordPress GZIP compression in your FTP client, force hidden files to show.

Once you locate the .htaccess file, start editing it. Or, to be safe, download the file on your computer and first make changes on your own hard drive. The file is likely also hidden by default on your own machine, so force hidden files to show.

Add the following code, sourced from GTmetrix, below the sections marked by the # BEGIN WordPress and # END WordPress tags (beyond this, the specific location where you include the following code 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 use it to replace your original .htaccess file. Then, run your website through a GZIP compression checker tool (or verify the response headers) GZIP compression checker tool to make sure that you were successful.

2. Enable GZIP Compression on NGINX or IIS

While most shared hosting plans come with Apache web servers, you may be using something else, such as NGINX or Microsoft’s IIS.

enable gzip compression wordpress

Enabling GZIP compression for NGINX web servers is slightly different from modifying the .htaccess file available to you if you were running on an Apache web server.

If you’re running on NGINX (like Kinsta), you can enable GZIP compression in WordPress by looking for 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.

3. Contact Your Web Host to Enable GZIP Compression in WordPress

If you’re not comfortable making changes to your website files, it’ll be easier to ask your web host to enable WordPress GZIP compression for you.

Many web hosts, including all GoDaddy, Kinsta, and Siteground enable WordPress GZIP compression by default since it offers such noticeable performance benefits and is so easy to do, while 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 the changes yourself, reach out! In general, most web hosts will be willing to assist you with this query when you reach out to their customer support teams.

In general, most web hosts will be willing to assist you with this query when you reach out to their customer support teams.

4. Enable WordPress GZIP Compression with 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 space on your server.

Regardless, these plugins can help you to easily enable WordPress GZIP compression.

Enable GZIP Compression

Enable WordPress GZIP Compression

Many of the tools that include the option of enabling GZIP compression on your WordPress site are caching suites designed to optimize the performance of your site. Compressing HTML files, compressing JavaScript files, and compressing CSS files are surefire ways to improve your site performance.

However, Enable GZIP Compression does only one thing, and that is to help you enable and disable GZIP compression for your WordPress site if you are using an Apache web server.

PageSpeed Ninja

enable gzip compression

PageSpeed Ninja is a full WordPress performance plugin, which means that one of its features is the ability for you to easily enable GZIP compression in WordPress. To do so, open up the PageSpeed Ninja plugin using the WordPress dashboard. Go to Settings > Advanced. Select GZIP compression under the Enable Compression section.

W3 Total Cache

WordPress GZIP Compression

W3 Total Cache is considered to be one of the best WordPress caching plugins.

A note of warning: WordPress newbies can easily break their website when using W3 Total Cache without proper configuration.

If you know what you’re doing, you can also enable HTTP compression by going to the browser cache, and checking the box for HTTP compression.

WP Rocket

WordPress GZIP Compression
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 in your .htaccess file using the mod_deflate module.

WP Super Cache

WordPress GZIP Compression

WP Super Cache is another WordPress cache plugin that offers the option to compress code.

To enable WordPress GZIP compression using WP Super Cache, go to the WordPress dashboard > WP Super Cache > Advanced > check the box for Compress pages so they’re served more quickly to visitors.

Wrapping Up 🍙

While there are plenty of ways to improve your WordPress site’s speed and page load time, GZIP compression is one of the easiest ways to do it.

Don’t wait for slow page load times to affect your businesses bottom line. Check your website to determine if WordPress GZIP compression is enabled. If it isn’t, you have plenty of tools at your disposal to turn the tides in your favor.

Once you’re done with WordPress GZIP compression, there are still several additional tactics you can employ for improving page speed. Educate yourself and take advantage of the available options—like image optimization plugins or using a CDN.

And if you need help with your next enable GZIP compression in WordPress adventures, just reach out to us here at WP Buffs. We have several care plans that can suit the needs of many different 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

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

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.

No thanks, I'm happy with my MRR

The WPMRR Virtual Summit! A free online conference 100% focused on helping you make monthly recurring revenue work for your WordPress business.

wpmrrvsblue

✔️ Attend every session and panel for free

✔️ Access to live event with all your WP friends

✔️ Free MRR merch giveaways

✔️ WP Buffs donation of $1 per registrant to Lawyers for Good Government

✔️ Make subscription revenue a core part of your business