System. Web. Optimization compresses scripts and style sheets. optimization
1. Whether to allow style sheet compression BundleTable. EnableOptimizations = true;
In the BundleConfig operation in the MVC project, Microsoft has prepared CSS and JS compression for us. We can compress the style sheet and script of the template page in this place (there are too many subpages, therefore, compression is also performed ). This configuration file is in the App_Start folder, and Global. asax will enable this configuration file in the Global configuration file. After setting EnableOptimizations, you can allow compression and not allow operations.
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 sheets and script pages to create virtual paths.
1 page direct call: 2 @ Styles. Render ("~ /Content/themes/base/css ","~ /Content/css ") 3 @ Scripts. Render ("~ /Bundles/modernizr ") items are actually included in the third section. I came out independently. The main feeling is that I think he is a good guy.
The code is simple, but it is very suitable. I don't know if you have used AjaxMinify. You can compile the script and compress it into the smallest content.
However, all commands are required. However, in MVC4.0, System. web. optimization already contains this stuff. They are JsMinify and CssMinify. Don't underestimate these two classes, although there are only two public methods.
The above method is to use Scripts and Styles to introduce Scripts and style sheets to the page, and compress the script and style sheet compilation and input to the client without having to modify any code,
This not only effectively increases the difficulty of JSHack and reduces the file size. To achieve this goal, we only need to set an attribute in BundleTable to true !!
Introduction of css style sheets and js scripts in the ssh framework
Try writing relative paths directly?
To reference a css file, the format is themes/xxx.css.
To reference a JS file, the format is js/xxx. js.
Who will make a webpage? HTML and CSS style sheets should be used, and javascript scripts can be added to increase the dynamic effect.
3 copies have been sent .... (Hope to help you... At the same time, remember to adopt my answer ..
If you have any webpage problems, please go to our group or group-professional website production
140391953 (QQ Group for website and webpage creation)
-------------------------------- Not satisfied, you can hi me .. You can customize it according to your requirements ....
References: website and webpage creation (Group