I'm currently using ASP.NET MVC 4 CSS/JavaScript Optimizer. It works good with my own CSS/JavaScript, but I also want to use it with plugins. Each plugin has its own folder:
~/Content/css // my own css, ok
~/Content/plugins/rateit
~/Content/plugins/chosen
~/Content/plugins/...
I can add this files to optimizer:
var bundle = new Bundle("~/Content/opt", new CssMinify());
...
bundle.AddFile("~/Content/plugins/chosen/chosen.css", "*.css");
BundleTable.Bundles.Add(bundle);
But in this case, after optimization, css is in another folder and browser cannot find background images anymore. Is there any solution to automatically modify css path for background images?
I can copy all plugins in one folder, but with a lot of plugins, it's not a good idea.
MVC implements a process called minification on the bundled files. Minification removes all whitespace and renames variables to their shortest possible name, thereby removing all excess characters (and thereby excess file size) from the bundle. Because the file is smaller, it takes less time to download.
Bundling and minification can be enabled or disabled in two ways: either setting the value of the debug attribute in the compilation Element in the Web. config file or setting the enableOptimizations property on the BundleTable class. In the following example, debug is set to true in web.
Bundling is one of the features of MVC. By implementing this, we can improve performance request load time. Minification is the process of removing unnecessary data without changing its functionality such as removing white spaces, comments, converting the large variable names to small, etc.
What is minification. Minification is a = process of removing unnecessary comments, spaces from JavaScript / css file. Main intention of minification is to decrease the size of javascript / css files so that load time will get decreased. Functionality of javacript / css file remains same in minification.
Might have a look at RequestReduce. It's another .net based minifier/bundler and it will rewrite all urls in the minified/bundled css to be absolute. This includes fonts and background images. It will also automatically expand any imports in the css. Additionally, where it thinks it can, it will sprite the background images.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With