Asp. JS/CSS package compression for MVC 4 in net

Source: Internet
Author: User
Tags min

Packaging (bundling) and compression (minification) refers to a number of JS files or CSS files packaged into a single file and compress the practice, so you can reduce the browser need to download multiple files to complete the Web page display delay sense, can effectively reduce the volume of file cases, improve transmission efficiency, Provides a smoother browsing experience for users.

Today in the use of MVC4 packaging compression function @scripts.render ("~/bundles/jquery") when some confusion, asked what in the App_start folder under BundleConfig.cs file


1 2 3 4 Bundles. ADD (New Scriptbundle ("~/bundles/jquery"). Include ("~/scripts/jquery-{version}.js", "~/scripts/jquery.unobtrusive-ajax.js"));

It's okay to write, but


1 2 3 4 Bundles. ADD (New Scriptbundle ("~/bundles/jquery"). Include ("~/scripts/jquery-{version}.js", "~/scripts/jquery.unobtrusive-ajax.min.js"));

It's not possible to write it, but I have it in my catalogue.


1 "~/scripts/jquery.unobtrusive-ajax.min.js"

This file.

By debugging the trace found that the ". Min.js" file has been filtered within MVC

By decompile This DLL file

You can see the following decompile code:


1 2 3 4 5 6 7 8 9 10 11-12 public static void Adddefaultignorepatterns (Ignorelist ignorelist) {if (ignorelist = = null) {throw new Argumentnullexcep tion ("ignorelist"); } ignorelist.ignore ("*.intellisense.js"); Ignorelist.ignore ("*-vsdoc.js"); Ignorelist.ignore ("*.debug.js", optimizationmode.whenenabled); Ignorelist.ignore ("*.min.js", optimizationmode.whendisabled); Ignorelist.ignore ("*.min.css", optimizationmode.whendisabled); }

This allows us to know that MVC defaults to filtering out the files for suffix. intellisense.js,-vsdoc.js,. debug.js,. Min.js,. Min.css, which is why we're referencing the. min.js file does not work.

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.