This project is read-only.


Minification, compression, combination, and caching of JavaScript and CSS resources for ASP.NET and ASP.NET MVC web applications.


Add references to your project
  • WebPacker.dll
  • WebPacker.Mvc.dll (for ASP.NET MVC)
  • WebPacker.NLogLogger (for logging with NLog)
  • WebPacker.DotLessFilter (if LESS filter required)

Register the configuration section and WebPacker configuration in the web.config

  <section name="web.packer" type="WebPacker.Configuration.WebPackerSection, WebPacker" />

<web.packer enabled="true">
  <provider type="memory" url="/webpacker.axd" />
    <filter type="WebPacker.Filters.YuiCssMinifier" />
    <filter type="WebPacker.Filters.YuiJavascriptMinifier" />
  <packs source="~/Packs.config" />
Full description of the configuration you can see here.

Create a packages definition file that pointed in configuration

In the example above it is a file "~/Packs.config"

<packs monitoring="true" versionGenerator="lastModified">
  <pack name="styles" type="css" basePath="~/content">
  <pack name="scripts" type="javaScript" basePath="~/scripts">
Feel free to modify packages definition file online. It doesn't require restarting the web application.

Register the WebPacker route

In global.asax code-behind file:
  1. Import WebPacker and System.Web.Routing namespaces
  2. Add this to the first line of either RegisterRoutes() or Application_Start():
Register namespace WebPacker on a pages

Add following line to the configuration section system.web/pages/namespaces in web.config:
<add namespace="WebPacker"/>



You can include package by name

Or you can generate it on the fly

@Html.CssPack(new [] { "~/content/reset.css", "~/content/site.css", "~/content/page.css" })
@Html.ScriptPack(new [] { "~/scripts/jquery-1.5.1.js", "~/scripts/main.js" })


<%=WebPackerHtml.CssPack(new [] { "~/content/reset.css", "~/content/page.css" })%>
<%=WebPackerHtml.ScriptPack(new [] { "~/main.js" })%>

Last edited Sep 21, 2011 at 5:41 PM by pshkarin, version 8