Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any experience combining JS / CSS in MVC?

I'm planning to implement a solution for combining multiple js/css files into single files in my MVC project, but currently I doubt between the following two possibilities:

Telerik Extensions for ASP.NET MVC (www.telerik.com/products/aspnet-mvc.aspx)

  • Supports combining multiple files into one request
  • Supports groups of web assets
  • Supports caching groups
  • Caching is disabled when application is in Debug mode
  • Groups of assets must be defined in masterpage or (partial) view
  • Supports GZip compression
  • Supports CDN
  • More than only a compression / combining solution (eg. JQuery helpers)

Combres - WebForm & MVC Client-side Resource Combine Library (combres.codeplex.com)

  • Supports combining multiple files into one request
  • Supports minifying resources
  • Supports groups of web assets
  • Supports caching of groups
  • Supports versions of groups (invalidates the browser's cache and server's cache)
  • Supports debugmode (disables caching/minifying)
  • Groups of assets must be defined in a web config section
  • Supports GZip compression
  • A custom route must be added
  • Supports custom filters
  • Uses the YUI Compressor library

Does anyone has experience with one of these or maybe another combining solution? I'm particularly interested in YSlow scores (before and after) and/or compression statistics/performances.

like image 506
PB. Avatar asked Nov 03 '09 08:11

PB.


People also ask

Can we use JavaScript in ASP NET MVC?

JavaScript can be used in asp.net mvc.

Is HTML CSS JS MVC?

The MVC model also provides full control over HTML, CSS, and JavaScript. The Model is the part of the application that handles the logic for the application data. Often model objects retrieve data (and store data) from a database. The View is the parts of the application that handles the display of the data.


1 Answers

You could use MvcContrib.IncludeHandling. Supports:

  • Combining multiple files into one request
  • Combining CSS
  • Combining JS
  • Debug-mode via MvcContrib.Filters.DebugFilter
  • Cache-headers
  • GZip / Deflate compression
  • Configuration
  • Swapping out the default implementations of the parts it relies on with your own implementations (for example; swap out the cache with your own implementation)
  • Registering includes in views as well as masters - will ignore duplicate registrations.

All happens at run-time; no build-steps etc required. No custom route required. Uses YUICompressor.

like image 107
Peter Mounce Avatar answered Oct 02 '22 21:10

Peter Mounce