c# - Minifying and combining files in .net -
i looking @ implementing performance optimization around javascript/css. in particular looking achieve minification , combining of such. developing in .net/c# web applications.
i have couple of options , looking feedback on each:
first 1 clever tool came across chirpy via visual studio combines, minifies etc -> http://chirpy.codeplex.com/ visual studio add in in team environment, tool isnt ideal.
my next option use msbuild task (http://yuicompressor.codeplex.com/) minify files , combine them (maybe read xml file needs combined). while works minifying fine, concern have have maintain must combined headache.
3rd option use msbuild task minifying , @ runtime using helper classes, combine files on per page basis. combine files, give name , add version it.
any other options consider? concern last option may have performance issues have open file local drive, read contents , combine files. alot of processing @ run time. looking @ squishit - https://github.com/jetheredge/squishit/downloads minifies files @ run time @ doing @ compile time.
so feedback on approaches great? if 3rd option not cause performance issues, leading towards it.
we have done similar several asp.net web applications. specifically, use yahoo yui compressor, has .net library version can reference in applications.
the approach took generate necessary merged/minified files @ runtime. wrapped logic asp.net control, isn't necessary depending on project.
- the first time request made page, process through list of included js , css files. in separate thread (so original request returns without delay) merged included files (1 js, 1 css), , apply yui compressor.
- the result written disk fast reference in future
- on subsequent requests, page first looks minified versions. if found, serves up. if not, goes through process again.
as icing cake:
- for debug purposes, if query string ?debug=true present, merged/minified resources ignored , original individual files served instead (since can hard debug optimized js)
we have found process work exceptionally well. built library our asp.net sites can take advantage. post-build scripts can complicated if each page has different dependencies, run-time can determine quite easily. and, if needs make quick fix css file, can so, delete merged versions of file, , process automatically start on without need post-build processing msbuild or nant.
Comments
Post a Comment