How to Enable GZIP Compression to Speed Up WordPress

How to Enable GZIP Compression to Speed Up WordPress

Have you enabled GZIP compression to speed up WordPress website yet?

GZIP compression is one of the easiest ways to optimize your website’s loading speed. Search engines like Google and Yahoo also accept this method. Despite that, only a few percentages of web owner implement it on their site. If you want a faster website then you need to enable it ASAP! 

Having said that, let’s dive into how to enable GZIP compression to speed up WordPress.

What is GZIP Compression?

GZIP stands for GNU Zip. This is actually a very popular method to compress web files like HTML, CSS, PHP and even Javascript. It is a simple and effective way to improve your site’s speed by reducing the size of the web content up to 80 percentage. 

If you’re wondering why you need to activate GZIP compression then the answer is simple. Enabling gzip compression helps to improve page load time, decrease bandwidth usage and also reduce SSL overhead.

The working mechanism of GZIP compression is also fairly easy to understand. When a user visits your website, servers send a compressed zip file to the user’s browser. Then the web date will automatically get extracted and displayed on the user’s browser. That’s how the page gets loaded quickly.

Check Your URL

There is a slight possibility that GZIP compression is already enabled on the server your website is hosted on. Before we begin, make sure whether GZIP compression is already activated or not on your site. You can carry out the GZIP compression test to check it.

Enable GZIP Compression Using .htaccess File

If your website is on Apache web servers then you can enable GZIP compression via adding a few codes on the file.

Editing .htaccess file can be a bit risky. Hence it is recommended to backup your .htaccess file before modifying it. However, anyone can enable GZIP compression to speed up WordPress using .htaccess file with proper guidance. 

  • First of all, navigate to the WordPress site’s root folder either by using the File Manager app in your hosting account’s cPanel dashboard or simply download an FTP client. We’ll use Filezilla for the sake of this tutorial. 

Then locate the .htaccess file in your root folder. Now, right-click it and open it in edit mode.

  • Now add the given code to it at the end.
<IfModule mod_deflate.c>
# 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
</IfModule>
  • Upload the edited file to the same location. If FileZilla asks permission to overwrite it, click OK.

Using WordPress Plugins

If you don’t want to edit core WordPress files then this method is for you. There is a WordPress plugin available that will do the work for you upon activation. The Enable Gzip Compression plugin is a perfect option to enable and disable Gzip compression on your WordPress site. Some other performance optimization plugins such as WP Fastest Cache plugin,  WP Super Cache or WP Rocket also do the same work. 

If you face any problem while trying to enable GZIP compression to speed up WordPress, simply contact your hosting provider.

That’s it! You’ve successfully enabled GZIP compression on the WordPress website. After that, you can check your site’s speed in the GTMetrix tool.

GTmetrix tool

Final Thoughts

Hence, this is how to enable GZIP compression to speed up WordPress. I hope you find WordPress tip useful to boost up your website performance. You can also follow us on Facebook and Twitter.

Don’t hesistate to ask any questions in the comment section below:

You might also like to read other articles:

One thought on “How to Enable GZIP Compression to Speed Up WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *