WordPress Code Snippets

A fresh mix of code snippets and tutorials

.htaccess enable compression


Two quick code snippets for compressing your file output with Apache’s mod_deflate. Compressing your content is a great way to improve performance by decreasing the amount of data that is sent to the client.

To compress all of the file types included in the following code, add the snippet to your site’s root .htaccess file:

Feel free to add more file types or remove any that are not required or not in use.

Alternate version

Here is an alternate version that is better suited if your site needs to accommodate older browsers (like if you’re working on a company Intranet or similar):

As before, you can add/edit/remove any file types as needed. The code itself enables compression for the specified files unless the browser is older Firefox or IE. Good times.

Further Reading

Learn more

.htaccess made easy

Show Support

Like our new Facebook Page to show support!