Simple and efficient JavaScript and CSS minification for ASP.NET MVC
CacheTag helps speed up your page load times in a number of ways.
CacheTag provides a number of benefits compared to other similar frameworks.
Let's say you want to include a couple of CSS files and JavaScripts, you can try this..
@Html.RenderStyles(new []
{
"~/CSS/Reset.css",
"~/CSS/Site.less"
})
@Html.RenderScripts(new []
{
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/app.coffee"
})
.. and that's it. Check out what this would produce below.
The example above would minify and combine the resources, calculate a unique hash and output HTML similar to this.
<link rel="stylesheet" type="text/css" href="/_cachetag/e4dddf2cdd91d693e023cdc5dc0b56d8664766db.css" /> <script src="/_cachetag/80e9e6fc43c6644ea9badec99eb5c6cbec87c4b0.js" type="text/javascript"></script>
In debug mode however, it would still calculate hashes of all resources but link to them individually, each with a query parameter containing the hash, this is to ease debugging but still prevent you from accidentally using stale scripts or CSS.
<link rel="stylesheet" type="text/css" href="/CSS/Reset.css" /> <link rel="stylesheet" type="text/css" href="/CSS/Site.less" /> <script src="/Scripts/jquery-1.7.1.js" type="text/javascript"></script> <script src="/Scripts/app.coffee" type="text/javascript"></script>