简体   繁体   English

Asp.Net MVC中JS和CSS的最小化

[英]minification Of JS And CSS In Asp.Net MVC

I'm working with Asp.Net MVC And i Use Jquery and Requir JS To Load JavaScript Files Like This: 我正在使用Asp.Net MVC,并且我使用Jquery和Requir JS来加载JavaScript文件,如下所示:

   require(['backboneModal', 'ModalDialog', 'Java Script File Name'], function (backboneModal, ModalDialog, OpenSavedFilterModal) {

        OpenSavedFilterModal.getModal(portFolioNameSpace); 
    });

now i want to minification Java Script Files: i use Squishit For Java Script Files Which load in Views like this: 现在我想缩小Java脚本文件:我将Squishit用于Java脚本文件,该文件在如下视图中加载:

   @Html.Raw(SquishIt.Framework.Bundle.JavaScript()
            .Add("~/Scripts/example.js")
            .ForceRelease()
    .Render("~/scripts/combined_#.js")

) and it works .but files which loaded with Required don't change ),并且可以正常运行。但是加载了Required的文件不会更改

I would personally use bundles that come with the nuget package Microsoft Web Optimization. 我个人将使用nuget软件包Microsoft Web Optimization附带的捆绑软件。 https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/ https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/

This way you can still reference the files from js. 这样,您仍然可以引用js中的文件。

http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification http://www.asp.net/mvc/tutorials/mvc-4/bundling-and-minification

Haven't used squish it or requir though so I might be wrong 没用过挤压或要求,所以我可能是错的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM