Scroll to top
USA
651 N Broad St, Suite 206,
MiddleTown, New Castle,
Delaware - 19709
Canada
635 Ashprior Avenue,
Mississauga, Ontario,
Canada - L5R3N6
India
34, Shiwanshu Bunglows
Vadodara, Gujarat - 390007

How To Enable GZIP Compression In WordPress?

93 / 100

How many actual ways are there to increase the page speed in a WordPress site? Every new article that you read brings you a piece of new information. They may be correct but they don’t tell you the percentage increase in page speed after doing what they asked you to do.

There are many tricks to increase page speed but the results are close to nothing. That is why I bring you a guaranteed solution for increasing your website’s page speed significantly.

According to torquemag.io: 

what’s remarkable is that this small step (enabling GZIP Compression) reduced our code from twelve characters to merely six, which is a reduction of 50 percent. The algorithm can reduce the size of HTML, CSS, and JavaScript files by as much as 70 to 90 percent.

You read that right. That is what a GZIP Compression is capable of! You can save up to 80 percent of your Bandwidth by using compressed site files.

One of the biggest benefits of this is being able to rank higher in SERPs. Google considers page speed as a criterion to rank websites and GZIP Compression can help you boost it like nothing else.

Now that I have convinced you how enabling GZIP Compression can help you, let me tell you a bit more about it.

What is a GZIP Compression in WordPress?

GZIP Compression was created by Jean-loup Gailly and Mark Adler as free software to replace the then used compression programs in UNIX Systems. GZIP is also just a software application and a file format used for file decompression and file compression.

In WordPress, GZIP helps in compressing all your website files including HTML, CSS, and JavaScript. You have to enable GZIP on the server-side so that all the files and folders can be compressed. 

But the Software has its limitations, It isn’t suitable for media files like images. A WAV file is compressed well with GZIP, but it isn’t the same for an MP3 file; it can increase the file size instead.

But the merits are unavoidable: all modern browsers support GZIP compression;  a web browser automatically asks for it while making an HTTP request.

So all you have to do is enable compression on your web server.

Why is GZIP Compression Important?

According to Neil Patel, 47% of consumers expect a web page to load in 2 seconds or less. Yes, that is right! Along with impacting greatly on the search engine results, it also helps in improving overall user experience.

When we talk about a website and its files and compression, we give importance to multimedia: images, GIFs and video. We ignore the fact that we have multiple files containing JavaScript, CSS, and HTML that make our whole website.

These files are large in file size and can take a lot of space on your web server. You may fail to take notice of these files but they negatively impact your page speed.

You can see the impact of files on the web server using the tools below:

How to check if GZIP Compression is Enabled?

GZIP Compression is a common feature that is enabled by hosting service providers as a default, but it may not always be the case.

The Best Way to do a GZIP test is to use an online GZIP Compression checker tool. The best ones around are: Base64.guru and Giftofspeed.com. All you have to do is paste your URL and voila!

Base64.Guru:

Check if GZIP Compression is enabled via online tool Base64.guru

GiftofSpeed.com:

Check if GZIP Compression is enabled via giftofspeed.com

You can also check if GZIP is enabled or not from your web browser. 

All you have to do is verify if the content-encoding: gzip HTTP response header is active or not on your website.

If you are using google chrome then go to the developer tools > network, click on any file then go to the Response header section.

Check GZIP Compression enabled or not from Response header.

If it isn’t enabled, don’t leave it there because now I am going to show you how you can enable compression.

How to enable GZIP Compression in WordPress?

As I mentioned earlier that compression is enabled on the server-side so WordPress itself has no involvement in it. But, many methods are designed for WordPress developers to enable GZIP compression.

So let us begin and get to know how we can enable compression on your Websites.

Enable GZIP Compression using .htaccess file (Apache)

Before beginning this method I’d recommend you take a full backup of your website.

Check out our blog on backups for WordPress to help you through it. 

As we know that .htaccess is a very sensitive file on the server, so taking a backup is a must because a small mistake is enough to break your entire website.

.htaccess file is available in your site’s root folder; it is also hidden on your web server and your machine as well.

The best practice is to use a File Transfer Protocol or FTP software that can help you to access the .htaccess file. You can even use cPanel but let us go with FTP .

Once you have the connection established with your server, force hidden files to show on your FTP client. Locate the .htaccess file and download it in your system. This is not a compulsory step but a precautionary method of editing.

Now, open the .htaccess file and add the following code below # BEGIN WordPress and # END WordPress tags. (source GTmetrix)

# 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

Important: Make sure mod_filter is loaded on your server, or the AddOutputFilterByType directive will not work and could cause a 500 error. We recommend checking your error logs if you have any issues with the code above.

Then replace the edited file with the actual .htaccess file on the web server and save it. Check your website in the above-mentioned online tools, or check the response header.

This method is suitable if your web server is Apache.

Enable GZIP Compression on IIS or NGINX

In this method, you don’t have to download any file on your system. If your server is using Apache then the .htaccess method is the best but if your web server is using NGINX then you can enable your GZIP Compression in WordPress adding the following code in your nginx.conf file:

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  your server is using Microsoft’s IIS which runs on windows then follow Microsoft’s official guide on how to enable GZIP Compression.

These are a few technical approaches to enable compression. Now let us see other approaches that you can take.

Enable GZIP Compression by contacting your Host

Many hosting services like Kinsta provide GZIP compression by default, and some like Siteground do not implement it for you but provide you the method to enable it yourself.

Check your website and if you do not have enabled compression on your site, and you are not comfortable making these changes on your own then you can always contact your hosting service’s customer support..

Enable GZIP Compression using a plugin

Yes, this is a method specifically for WordPress users. WordPress gives you the ability to add plugins created by amazing developers. These plugins can make your website faster, safer, and more visible. 

Want a faster, safer site that Google loves? Check out our guide on must-have plugins for 2020.

But before you go for a plugin,  make sure you go through the methods above first as adding plugins can harm your WordPress website too.

Can your WordPress site break? Read our top vulnerabilities in WordPress article to know more.

WordPress also has plugins to enable GZIP as well. Some of these plugins are:

Enable GZIP Compression

Enable GZIP Compression Plugin

This plugin doesn’t contribute to anything else to your website apart from enabling and disabling GZIP. This plugin sure will increase your website’s load speed by making sure that all the JS, CSS, and HTML files are compressed files.

PageSpeed Ninja

img 5f4b3d1e01c0e

This plugin doesn’t contribute to anything else to your website apart from enabling and disabling GZIP. This plugin sure will increase your website’s load speed by making sure that all the JS, CSS, and HTML files are compressed files.

Just open up the PageSpeed Ninja plugin using the WordPress dashboard. Go to Settings > Advanced. Select GZIP compression under the Enable Compression section.

WP Rocket

img 5f4b3d1ec6a11

This is a caching plugin which makes sure that your site’s loading speed increases and the loading time decrease. It also provides facilities like Caching at CDNs (Content Delivery Network).

WP Rocket adds  GZIP Compression rules in .htaccess file using the mod_deflate module automatically when it is added to your website.

Conclusion

There are many articles about speeding websites,  but they do not have a significant impact on your site’s performance.  GZIP compression is one of the most powerful and easiest ways to achieve speed and get happy users.

There are a few other ways like adding a Content Delivery Network or image optimization that can increase  your website’s speed.

WP Uber provides you with solutions to boost your WordPress website, secure it, and make it impenetrable. Get started with us now!

Author avatar
Tim Michaels
I am into WordPress and web development for the last 10 years. I use my experience to help people just starting with WordPress. Follow my blog at WP Uber for everything related to WordPress.
We use cookies to give you the best experience.
Do NOT follow this link or you will be banned from the site!