Compressing resources with gzip or deflate can reduce the number of bytes sent over the network.
Page Speed recommends:
Write your web page content to make compression most effective
To ensure that your content compresses well, do the following:
- Ensure consistency in HTML and CSS code. To achieve consistency:
- Specify CSS key-value pairs in the same order where possible, i.e. alphabetize them.
- Specify HTML attributes in the same order , i.e. alphabetize them. Put href first for links (since it is most common), then alphabetize the rest. For example, on Google's search results page, when HTML attributes were alphabetized, a 1.5% reduction in the size of the gzipped output resulted.
- Use consistent casing, i.e. use lowercase wherever possible.
- Use consistent quoting for HTML tag attributes, i.e. always single quote, always double quote, or no quoting at all where possible.
- Minify Javascript and CSS. Minifying JavaScript and CSS can enhance compression both for external JS and CSS files and for HTML pages containing inlined JS code and style blocks.
Don't use gzip for image or other binary files:
Image file formats supported by the web, as well as videos, PDFs and other binary formats, are already compressed; using gzip on them won't provide any additional benefit, and can actually make them larger. To compress images, see Optimize images.
Read More