Just like image compression, gzip compresses files on your website which makes it load faster. There are plugins you can install that will do this for you, however some plugins can actually slow your site down or break certain features.
The leanest way to compress files on your WordPress site is by adding some code to your .htaccess file. Editing your .htaccess file allows you to change the configuration on your website without accessing the server side configuration files. All you need to edit .htaccess is access to your cPanel.
You should make sure that your website is not already using gzip or brotli. You can run a test here.
Step 1: Log into your cPanel

Step 2: Click on “File Manager”

Step 3: Click on “Public HTML”

Step 4: Right click your .htaccess file

Step 5: Click “Download” and save a backup of your file

Step 6: Right click Your .htaccess file again, this time click “Edit”

Step 7: If this pop-up appears, click “Edit”

Step 8: Copy this code
# Gzip Start
<IfModulemod_gzip.c>
mod_gzip_onYes
mod_gzip_dechunkYes
mod_gzip_item_includefile.(html?|txt|css|js|php|pl)$
mod_gzip_item_includehandler^cgi-script$
mod_gzip_item_includemime^text/.*
mod_gzip_item_includemime^application/x-javascript.*
mod_gzip_item_excludemime^image/.*
mod_gzip_item_excluderspheader^Content-Encoding:.*gzip.*
</IfModule>
# Gzip End
Step 9: Paste it to the bottom of your .htaccess file

Step 10: Click “Save Changes”
You can run the gzip/brotli test again here. If the test does not recognize the compression, you can either wait a few hours and try again, or purge your website cache.
Now that you know how to speed up your WordPress site with gzip, why not sign up for our newsletter to get more tips every week?
Unlock Weekly Wisdom!
Dive deep into web development and business topics with our curated newsletter, delivered to your inbox every week.
Just like image compression, gzip compresses files on your website which makes it load faster. There are plugins you can install that will do this for you, however some plugins can actually slow your site down or break certain features.
The leanest way to compress files on your WordPress site is by adding some code to your .htaccess file. Editing your .htaccess file allows you to change the configuration on your website without accessing the server side configuration files. All you need to edit .htaccess is access to your cPanel.
You should make sure that your website is not already using gzip or brotli. You can run a test here.
Step 1: Log into your cPanel

Step 2: Click on “File Manager”

Step 3: Click on “Public HTML”

Step 4: Right click your .htaccess file

Step 5: Click “Download” and save a backup of your file

Step 6: Right click Your .htaccess file again, this time click “Edit”

Step 7: If this pop-up appears, click “Edit”

Step 8: Copy this code
# Gzip Start
<IfModulemod_gzip.c>
mod_gzip_onYes
mod_gzip_dechunkYes
mod_gzip_item_includefile.(html?|txt|css|js|php|pl)$
mod_gzip_item_includehandler^cgi-script$
mod_gzip_item_includemime^text/.*
mod_gzip_item_includemime^application/x-javascript.*
mod_gzip_item_excludemime^image/.*
mod_gzip_item_excluderspheader^Content-Encoding:.*gzip.*
</IfModule>
# Gzip End
Step 9: Paste it to the bottom of your .htaccess file

Step 10: Click “Save Changes”
You can run the gzip/brotli test again here. If the test does not recognize the compression, you can either wait a few hours and try again, or purge your website cache.
Now that you know how to speed up your WordPress site with gzip, why not sign up for our newsletter to get more tips every week?
Unlock Weekly Wisdom!
Dive deep into web development and business topics with our curated newsletter, delivered to your inbox every week.