Question

I have the following bundling config:

bundles.Add(new ScriptBundle("~/bundles/superfish").Include(
            "~/Scripts/superfish.js",
            "~/Scripts/supersubs.js",
            "~/Scripts/hoverIntent.js"));

bundles.Add(new StyleBundle("~/bundles/superfish/css").Include(
            "~/Content/megafish.css",
            "~/Content/superfish-navbar.css",
            "~/Content/superfish-vertical.css",
            "~/Content/superfish.css"));

I have the following files in the /Scripts folder:

"~/Scripts/superfish.js",
"~/Scripts/superfish.min.js",
"~/Scripts/supersubs.js",
"~/Scripts/hoverIntent.js"

Questions:
a) Should I or not include the ".min" file in the bundle?
b) If not, what is the rule that automatically idenfity the min file? Say, could I use the
~/Scripts/superfish-src.min.js instead of
~/Scripts/superfish.min.js?
Or sometimes the min files are included all in a "minified" folder. How does the framework know where to search for them?
c) is there a min version for the css files?

Was it helpful?

Solution

ASP.NET MVC both combines and minifies JS and CSS. It has two built in handlers for this: JsMinify and CssMinify, respectively. There's nuget packages that allow you to substitute these for other minification algorithms, such as JsMin, YUI, etc.

If a file with .min exists, it is assumed that you have handled the minification yourself, and that file will be combined (but not minified again) with the rest of your resources.

Both bundling and minification occurs only in release configuration. So you would have to publish and deploy your app with the release config, before you'll see anything happen. In debug config, MVC serves up each resource, unmodified, individually.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top