How to Enhance Website Speed

April 30, 2010 – 2:33 am

Continued…

 

3) Compression Techniques: Compressing CSS, JavaScript and PHP

Compressing PHP, HTML, JavaScript and CSS content leads to a reduction in page size, which results in the pages being served faster to the browser.

  • Compress all text and html:

AddOutputFilterByType DEFLATE text/html text/plain text/xml

  • Or, compress certain file types by extension:

<Files *.html>

SetOutputFilter DEFLATE

</Files>

  • Also, you can add following code in your htaccess file and enable compression using mod_gzip.

<IfModule mod_gzip.c>

mod_gzip_on Yes

mod_gzip_dechunk Yes

mod_gzip_item_include file (html?|txt|css|js|php|pl)$

mod_gzip_item_include handler ^cgi-script$

mod_gzip_item_include mime ^text/.*

mod_gzip_item_include mime ^application/x-javascript.*

mod_gzip_item_exclude mime ^image/.*

mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

</IfModule>

4) Other Practices for enhancing website speed:

  • Put StyleSheets at the top
  • Put Scripts at the bottom
  • Make JavaScript and CSS external
  • Minify JavaScript and CSS
  • Optimize images
  • Do not scale images in HTML

Hope all these points will help you to enhance your website speed. Do comment!

Post a Comment

*Please fill correct value in the text box given below.