Enabling gzip compression on your script / webserver will not only help you achieving a greater score on Google PageSpeed “Enable compression” [1] test, but also allow a faster rendering time on your visitors browser.
The easiest way to achieve it, providing your are using PHP, is to add a few lines at the beginning of your PHP script to activate zlib output compression [2] :
You can also add the following piece in your htaccess file, which will tell Apache to compress the corresponding files, providing the mod_deflate is activated on your server :
Fig 2 : Google Page Speed – Score before activating gzip compression of 72 on mobileFig 3 : Google Page Speed – Score after activating gzip compression of 89 on mobileFig 4 : Google Page Speed – Score before activating gzip compression of 79 on desktopFig 5 : Google Page Speed – Score after activating gzip compression of 89 on desktop
Links and credits
[1] – Optimizing encoding and transfer size of text-based assets — Web Fundamentals – developers.google.com