System.Web.Optimization compression operations on scripts and style sheets

Source: Internet
Author: User

The bundleconfig operation in the MVC project is that Microsoft has prepared CSS and JS compression for us, we can put the template page style sheet and script into this place compression (too many sub-pages, so another compression). This configuration file under the App_start folder, Global.asax in the global profile, will enable this profile, after the enableoptimizations settings, you can allow compression and do not allow operation

1 bundles. ADD (New Stylebundle ("~/bundles/styles/benefits"). Include ("~/content/benefits/benefitsmaster.css", 2 "~/content/benefits/benefitshead.css")); 3 bundles. ADD (New Scriptbundle ("~/bundles/scripts/base"). Include ("~/scripts/sea.js", 4 "~/scripts/seajs/style.js", 5  "~/scripts/seajs/combo.js", 6  "~/scripts/seajs /config.js ", 7" ~/scripts/fmall/init.js ")); 8 Compress the style sheet, script page, and create the virtual path, respectively
1 Page Direct call: 2 @Styles. Render ("~/content/themes/base/css", "~/content/css") 3 @Scripts. Render ("~/bundles/modernizr") The item is also contained in three, I am independent, the main feeling is that I think he is a good guy.
Code is simple, but very applicable, do not know if you have used ajaxminify this east, can be compiled, compressed into the smallest content.

By using scripts and styles to introduce scripts and style sheets into a page, the script and stylesheet can be compiled and compressed into the client without modifying any code, as described above.
This can not only effectively increase the difficulty of jshack and reduce the size of the file. To achieve this, we only need to set a property in Bundletable to True!!

System.Web.Optimization compression operations on scripts and style sheets

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: info-contact@alibabacloud.com 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.