How to Setup GZIP in WordPress Without a Plugin

What is GZIP Compression?

GZIP is a file format and a software application used for file compression and has to be enabled server-side. GZIP compression allows you to compress the size of your HTML, CSS, and JS files. It’s possible to get up to a 90% reduction in file size after enabling GZIP. It’s also one of the quickest and easiest optimizations you can make when it comes to speeding up WordPress.

If you have ever tested your website on Google Page Insights, GTMetrix or Pingdom you might have seen this optimization recommendation. GZIP compression is an important speed optimization that can make your website load considerably faster.

How to Setup GZIP in WordPress

Setting up GZIP in WordPress is very easy, all you will need to do is copy and paste several lines of code to your .htaccess file. This code will instruct your server to compress all outgoing files before being sent to your visitors.

There are plugins out there that can enable GZIP for you, but I like to limit the number of plugins that I use to avoid problems and conflicts. Another reason you don’t really need a plugin for this is because enabling GZIP is extremely easy to do yourself. In the tutorial below, I will show you how to set this up without a plugin.

Step 1: Make sure GZIP is Enabled

The first thing you will need to do is make sure GZIP compression is enabled for your server. To determine if your web host supports GZIP compression, create a file named test.php that contains the following code and upload it to your server root.

<?php phpinfo(); ?>

Open the test.php page in your browser ex: If GZIP compression is listed and enabled, you should be able to move on to the next step.

Step 2: Locate your .htaccess File

Login to your cPanel and go to the File Manager. The .htaccess file is hidden by default. You will need to find the settings icon on the top right and change the option to show hidden files.

After you enable Hidden Files (dotfiles) you should be able to find the .htaccess file located in the your public_html folder.

Step 3: Edit your .htaccess File

Right click the .htaccess file and choose edit. Copy and paste the code below inside the file:

# BEGIN GZIP Compression

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
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

# END GZIP Compression

Make sure you save your changes and close the file editor.

Step 4: Make Sure Everything is Working

All that is left to do now is check your website and see if GZIP is working. You can use this website Gift of Speed to check it. This website will test if the webserver sends the GZIP command to your clients. You will also be able to see how much each page was compressed by using GZIP.

Enter your website URL in the box and hit enter. If you get the message: “GZIP Is Enabled” then everything is set up and should be working correctly.

If you enjoyed this tutorial, please be sure to follow us on Facebook and Twitter. You can also find us on Freelancer if you need some help with your WordPress website or web development issues.

David Green

My name is David and I am the founder and author of Zuziko. I love WordPress and have built sites, themes and plugins. I am passionate about web development and have created Zuziko as a way to share my knowledge and experience with the world. My WordPress user profile.

Leave a Comment

Share via
Copy link
Powered by Social Snap