How to compress my CSS with gZIP?

In order to compress your CSS files with gZIP there are two things that you should do.

First, add the following line to the .htaccess file in your public_html folder:

 

 

By doing this, you allow the server to process .css files through PHP.

Next, add the following lines at the very beginning of your .css file(s):

 

 

By doing this, you will enable the gZIP compression for your CSS file. For bigger websites there will be a significant improvement in the loading speed of your pages.

You can also use the Apache modules called mod_deflate and mod_expires in order to compress your CSS, js and image files. You can place the following rewrite rules inside the .htaccess file situated in the public_html folder:

 

 

You can check the effect using this optimization tool – http://analyze.websiteoptimization.com

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Brute Force Attack – What it is and How to Block It

Brute-force is a method of guessing your password by trying combinations of letters, numbers and...

What is pdftoppm and is it supported by Hostlantern?

Pdftoppm is a library that handles the conversion from Portable Document Format (PDF) files to...

How to clear your Internet browser’s cookies?

Sometimes you may need to clear the cookies saved by your browser. Basically the cookies...

Hacked Website

The most common reasons for a hacked (defaced) website include: - Outdated web application....

How to clean my files from malicious code?

If your website has been hacked and malicious content has been inserted into your files, you...