Are you worried about your website page speed and page loading time? Do you see a bad Google PageSpeed Insight score for your website? Then you may like to “Enable Gzip Compression in WordPress” in order to optimize your website speed.
In this article, you will learn how to enable Gzip Compression to make your site load faster. To get fast load times on your WordPress site, reducing the size of your pages is important.
Enabling GZIP compression can help reduce the size of your webpage, which can significantly decrease the amount of time to download the resource, reduce data usage, and improve the time to first render of your pages.
Gzip compression is one of the most effective ways to make your site load faster, which is also sometimes called HTTP or browser compression.
What is GZIP Compression?
GZip Compression –
- Compress 100kB file to 10KB.
- Reduces Page sizes & Increase page speed.
- Enable compression warning in Google PageSpeed Insights.
- Enable GZIP compression warning in GTmetrix
How ZGip Compression Works
Before moving on to how to implement it, let’s first take a look at what compression means and how it can help.
Compression algorithms such as gzip use the patterns and repetitions found within the text to create a more efficient way of storing data. Let’s look at an example.
Here’s some HTML code to make the text within it display in bold:
<strong>this is bold</strong>
The compressed version of this is actually pretty long:
However, take a look at what happens when we compress the following:
<strong>this is bold</strong> <strong>this is bold too</strong>
The compressed version is:
Even though the original text is more than double the size, the compressed version is actually only 16 characters more — a whopping 32% reduction in size, which means less to load and a faster website.
Enabling GZip Compression for WordPress
If you don’t have GZIP compression enabled, don’t get panic. Let’s have a look at a couple of ways you can go about enabling it on your web server. You, need to understand that compression is not handled by WordPress itself but, through a server configuration.
Enable Gzip Compression in WordPress via .htaccess
To enable Gzip Compression in WordPress via .htaccess, you need to Log into your cPanel and follow the following steps.
- Under file section, select file manager menu.
- Check the checkbox show hidden files and click Go.
- Under public_html folder of your website, find and edit the file called .htaccess.
- Paste the following code into the .htaccess file at the end of your existing content.
The instructions and code above will work on Apache. If they are not working there is another way that may work for you. If the above code did not seem to work, remove it from your .htaccess file and try this one instead.
- DEFLATE Compression – Copy and Paste the following code in WordPress .htaccess file of your website.
Ask Your Host
First things first: since enabling compression requires you to edit (or even create) a sensitive file that isn’t the easiest to work with (known as an ‘htaccess file‘), if you’re in any doubt about what to do, it may be best to ask your host to do it for you. If you’re with a top-notch host with top-notch support, they should be able to set this up for you (if they haven’t already) within a matter of minutes.
Enable Gzip Compression with WordPress plugin
Here, is some sort of plugin solution to set up Gzip compression. One of the easiest way using a plugin that supports enabling GZIP.
- “WP HTTP Compression Plugin“, This plugin allows you to output the pages in Gzip compressed format, allows your WordPress blog to output pages compressed in gzip. HTTP compression generally means a 60-80% REDUCTION in the size of your pages (broadband usage) as well as an INCREASE in download speeds of 3x to 4x. Download, install and activate ⇒ https://wordpress.org/plugins/wp-http-compression
- “WP Super Cache“, Another plugin option which generates static HTML files from your dynamic WordPress blog. After an HTML file is generated your web server will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts, You can find an option to Compress pages so they’re served more quickly to visitors. Download, install and activate ⇒ https://wordpress.org/plugins/wp-super-cache/
- “WP Rocket“, It also helps to boost the performance of its site without effort and improve the user experience. Furthermore, support is effective and responsive! but also comes with compression built in. Download, install ⇒ https://wp-rocket.me/
Test Your Work
There are a number of ways to check whether or not a site’s files are gzip compressed, with one of the easiest (and most interesting) by using the wonderful GTMetrix site testing tool.
If all is working as it should be, you should be able to see the following within the ‘Waterfall’ section of your site’s GTMetrix results:
Update: for a slightly more in-depth gzip check, the website Check GZIP Compression is a handy resource.
Gzip compression is one of those simple speed fixes to add (or have added) to your site — whether it be powered by WordPress or otherwise. If you don’t enable it, you could be missing out on a significant speed boost.
Final note: if you’re interested in learning more about a site’s htaccess file, I’d recommend taking a look at the excellent htaccess guide from Tuts+, which includes heaps more info and a number of great tidbits you may be able to use to your site’s advantage.