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.