Articles, tips and tricks, news and other little things to do better our job!

lunedì, gennaio 10, 2011

Minimize Javascript and CSS files

One of the first optimization I've done to improve the network performance of a website was to decrease the number, the position and the size of the files Javascript and Css included on a web page.

In order to render fastest a page the Css files have to be at the begin of the page, the Javascript files at the end.

Aggregate more files, of the same type, in one single file (or more files separated for macro area) reduces the elaboration time.

So minify that files is the last operation. Minified a file means remove all characters, white space etc that are necessary to write and debug an application but are useless for a browser. This operation reduces the files size.

On the continuous integration server I use the Microsoft Ajax Minifier 4.0 with a C# console program that search and minimizes all files in a batch process ;)

The source project could be downloaded here: Ajax Minifier Batch Source
The executable here:  Ajax Minifier Batch Bin

EX: AjaxMinBatch.exe -D "c:\mySolution\web" -OW true -A true

Search and overwrite all Css and Javascript files in the directory and subdirectory.


Enjoy!

0 commenti:

Cerca nel blog

Caricamento in corso...

About This Blog

Mauro Bennici è Software Architect specializzato in .NET.

Back to TOP