Minify + Compress Website Assets for Faster Performance


To increase website performance, one best practice is to minify and compress your assets and put them on a CDN.

Minify
To minify assets like CSS and Javascript files, there are many tools available.  YUI Compressor seems to be one of the best for compressing Javascript files.

Compress
To compress assets like CSS and Javascript files, there are manytools available. Gzip seems to be one of the best ones. On Windows, you can use 7-Zip to do the compression as shown below.

CDN
One cheap CDN you can use is Amazon’s CloudFront. It has a web interface as well as an API.  You first upload files to Amazon S3 and then reference your files using the CloudFront URL. Just remember to set your files metadata correctly as shown below for javascript.

For CSS files, you would set the Content-Type value to “text/css” without quotes.

Including files
When referencing files in your web pages, using protocol-less URLs, e.g.

<link charset=”utf-8″ href=”//d1dejaj6dcqv24.cloudfront.net/vendors/jquery-ui.selectmenu/jquery-ui.selectmenu-1.2.0.min.gz.css” rel=”stylesheet” type=”text/css”>

Copy from http://www.abdullahyahya.com/2012/07/30/minify-compress-website-assets-for-faster-performance/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s