How To Enable GZIP Compression In WordPress?

How To Easily Enable Gzip Compression For WordPressCompression is an extremely common concept. If you’ve spent any time working with computers, you’re probably already familiar with it. For those who are unfamiliar: compression is a very useful tool for combining many files into one significantly smaller (and more readily transportable) file, which translates to faster page load times for websites.

In this post, I’ll look at how gzip compression works, compress components with gzip wordpress and how you can enable it on your own WordPress-powered website.

How Compression Works

Let’s begin by looking at what compression is and how it might help.

The majority of contemporary websites are built on a combination of HTML, CSS, and JavaScript, which are all written in a logical, internationally accepted manner by professional software developers. The end result is generally a lot of overhead that does little more than enhance human readability. Furthermore, most coders will use similar design patterns and common components, resulting in significant.

The strategies used by data compression algorithms such as gzip employ patterns and repetitions found in the text to create a more efficient way of storing information. Consider the following scenario.

Here’s some HTML code to make the text within it display in bold:

<strong>this is bold</strong>

This is, in fact, a fairly lengthy phrase.: eNqzKS4pys9LtyvJyCxWAKKk/JwUG32oIC8XALn8Cuo=. However, compare the following with what happens when we compress it:

<strong>this is bold</strong>
<strong>this is bold too</strong>

The compressed version is eNqzKS4pys9LtyvJyCxWAKKk/JwUG32oIC+XDRZphZL8fCQlACNDF0U=. Despite the fact that the original text is more than twice as long, the compressed version is only 16 characters longer — a 32% reduction in size, which means less to load and faster website loading.

How to Enable GZIP Compression to Speed Up WordPress Sites?

 

It’s vital to note that WordPress isn’t in control of gzip compression. It’s actually handled by the servers themselves (rather than within WordPress), so you’ll need to set it up outside of WordPress to enable it.

ASK YOUR HOST:

 

The first and most important thing to keep in mind is that you must modify (or even create) a file that is not necessarily the simplest to deal with (known as an “access file” ), so if you’re not sure what to do, ask your host to handle it for you.

SETTING THINGS UP ON YOUR OWN

A hidden file, named .htaccess, is used to give a server special directions like redirection or automatically adding files to specific requests, among other things—and it’s even capable of enabling gzip compression! Finding and then editing this difficult file may be the tricky part.

The first thing you’ll need is access to the files on your server. For most people, the easiest way to get access is using FTP. However, because a site’s htaccess file is a “dot-file” (meaning it’s typically hidden), finding it may be more difficult than usual.

Second, while it’s possible to hide a file with CSS and JavaScript alone, doing so becomes more difficult as the file grows larger. Even worse, because it’s a hidden file, if you store it on your computer, in the same manner, you would a regular file, it’ll stay hidden, making editing very hard.

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

That’s all there is to it — you’re done! Your text-based material, such as HTML, CSS, and JavaScript, should now be transmitted in its gzipped form.

Check gzipped compression by GTMetrix

 

There are several ways to check whether or not a site’s files are gzipped compressed, with one of the simplest (and most fascinating) being via the excellent GTMetrix site testing tool – something we’ve already discussed in an earlier post: How to Use GTMetrix to Test a Website’s Speed Effectively!

After that, you should notice the in your GTMetrix results under the “Waterfall” category.

Conclusion

 

Gzip compression, like most things related to web performance, is one of those easy yet effective ways (or tasks) to improve (or add) your site’s speed without having to make any changes in code. If you don’t enable it, you’ll be losing out on a significant speed boost.

Finally, if you’re interested in learning more about a website’s htaccess file, I’d recommend reading Tuts+’s excellent htaccess guide, which has a lot more information and a few useful nuggets that you might use to your site’s advantage.

author avatar
Chris Digital
Chris Digital, tech enthusiast and digital marketer, shares insights on WordPress, SEO, Adsense, online earning, and the latest in graphics and themes.

Leave a Comment