Web-en

How to enable GZIP compression WordPress

Enable gzip compression in WordPress

In order to render your web pages faster from WordPress, and to score higher on Google PageSpeed Insights, especially on the Enable Compression test, you should activate Gzip compression. You can check if that’s the case for your website on gidnetwork.

WordPress GZIP compression test

Quick hint : best solution is to activate gzip compression for WordPress with PHP by adding this code at the beggining of your wp-config.php file:

ini_set("zlib.output_compression", "On");
 ini_set("zlib.output_compression_level", "-1");

Activate gzip compression for WordPress with PHP

How to enable GZIP compression WordPress : Add code in the wp.config.php file
How to enable GZIP compression WordPress : Add code in the wp.config.php file

Best WordPress compression plugin

Many plugins promise to make it happen : Gzip ninja speed compression, W3 Total cache, but sometimes it just doesn’t work.

Gzip ninja speed compression WordPress plugin
W3 Total Cache WordPress plugin

After trying these plugins, this is the result we got – gzip compression wasn’t working, either with plugins or with htaccess update.

How to enable GZIP compression WordPress : Compression not activated, checked on gidnetwork
How to enable GZIP compression WordPress : Compression not activated, checked on gidnetwork

The score on Google PageSpeed Insights for our website were pretty bad:

How to enable GZIP compression WordPress : Bad score on Google PageSpeed Insights due to activate compression
How to enable GZIP compression WordPress : Bad score on Google PageSpeed Insights due to activate compression

Therefore, the best solutions are to update your htaccess, or, if still not working, to add the code mentioned above, to get following results – unfortunately, external scripts can only be improved by their owners.

Enable GZIP compression WordPress htaccess

Another solution is to enable GZIP compression in WordPress htaccess. To do so, simply open the htaccess file with a text editor, and add these lines somewhere in a new line in the file, and upload it back on the webserver with these changes included to enable GZIP compression WordPress:

#Compression
 
 AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/javascript
 

If your server allows compression and the mod_deflate is installed, then the GZIP compression for your WordPress site will be activated.

How to enable GZIP compression WordPress : Compression activated as checked on gidnetwork
How to enable GZIP compression WordPress : Compression activated as checked on gidnetwork
How to enable GZIP compression WordPress : Google PageSpeed insights results improved after activated gzip compression in WordPress
How to enable GZIP compression WordPress : Google PageSpeed insights results improved after activated gzip compression in WordPress