并置并在构建时的飞行或缩小JavaScript - ASP.NET MVC [英] Concatenate and minify JavaScript on the fly OR at build time - ASP.NET MVC
问题描述
进行了扩展,这个问题在这里<一个href=\"http://stackoverflow.com/questions/885990/linking-javascript-libraries-in-user-controls/886184#886184\">Linking JavaScript库在用户控件的我是人们如何串联并在飞行或在生成时缩小JavaScript的一些例子之后。我也想看看它,然后是如何工作到您的母版页。
As an extension to this question here Linking JavaScript Libraries in User Controls I was after some examples of how people are concatenating and minifying JavaScript on the fly OR at build time. I would also like to see how it then works into your master pages.
我不介意被缩小的网页的特定文件和链接inidividually,因为他们目前正在(见下文),但所有的主要母版页上的JavaScript文件(我有5或6)我想串联和精缩。
I don't mind page specific files being minified and linked inidividually as they currently are (see below) but all the JavaScript files on the main master page (I have about 5 or 6) I would like concatenated and minified.
奖励积分的人谁也采用了CSS级联和缩小! : - )
Bonus points for anyone who also incorporates CSS concatenation and minification! :-)
用,我想串连和缩小的共同JavaScript文件当前母版页:
Current master page with the common JavaScript files that I would like concatenated and minified:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<head runat="server">
... BLAH ...
<asp:ContentPlaceHolder ID="AdditionalHead" runat="server" />
... BLAH ...
<%= Html.CSSBlock("/styles/site.css") %>
<%= Html.CSSBlock("/styles/jquery-ui-1.7.1.css") %>
<%= Html.CSSBlock("/styles/jquery.lightbox-0.5.css") %>
<%= Html.CSSBlock("/styles/ie6.css", 6) %>
<%= Html.CSSBlock("/styles/ie7.css", 7) %>
<asp:ContentPlaceHolder ID="AdditionalCSS" runat="server" />
</head>
<body>
... BLAH ...
<%= Html.JSBlock("/scripts/jquery-1.3.2.js", "/scripts/jquery-1.3.2.min.js") %>
<%= Html.JSBlock("/scripts/jquery-ui-1.7.1.js", "/scripts/jquery-ui-1.7.1.min.js") %>
<%= Html.JSBlock("/scripts/jquery.validate.js", "/scripts/jquery.validate.min.js") %>
<%= Html.JSBlock("/scripts/jquery.lightbox-0.5.js", "/scripts/jquery.lightbox-0.5.min.js") %>
<%= Html.JSBlock("/scripts/global.js", "/scripts/global.min.js") %>
<asp:ContentPlaceHolder ID="AdditionalJS" runat="server" />
</body>
用于在这样的页面(这我很高兴):
Used in a page like this (which I'm happy with):
<asp:Content ID="signUpContent" ContentPlaceHolderID="AdditionalJS" runat="server">
<%= Html.JSBlock("/scripts/pages/account.signup.js", "/scripts/pages/account.signup.min.js") %>
</asp:Content>
更新:现在的建议(晚2013):
UPDATE: Recommendations for now (late 2013):
我想看看微软ASP.NET内置的捆绑和微小。
I would look at Microsoft ASP.NET's built in Bundling and Minification.
推荐答案
在专业ASP.NET 3.5 <的附录/一>斯科特Hanselman的谈论帕克为.NET 。这将与集成的MSBuild和包装JavaScript文件的生产部署等。
In the appendix of Professional ASP.NET 3.5 Scott Hanselman talks about Packer for .NET. This will integrate with MSBuild and pack javascript files for production deployments etc.
这篇关于并置并在构建时的飞行或缩小JavaScript - ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!