admin管理员组文章数量:1302270
How do you implement SquishIt to bundle Css/Js across View Pages and Render it in the Master page? I thought I could use a ContentPlaceHolder above the Render portion, but there seems to be some odd behavior where it sometimes adds 3 files (1 in the view page and 2 in the master page) but other times will ignore the file added from the View Page.
Index.aspx
<asp:Content ContentPlaceHolderID="CssFiles" runat="server">
<% CssHelper.Add("home.css"); %>
</asp:Content>
Site.master
<asp:ContentPlaceHolder ID="CssFiles" runat="server" />
<% CssHelper.Add("reset.css"); %>
<% CssHelper.Add("master.css"); %>
<%=CssHelper.Render() %>
My current solution is a Static wrapper around SquishIt's static Bundle class that keeps the BundleBuilder in HttpContext.Current.Items.
I'm curious if this has been done successfully and how so.
How do you implement SquishIt to bundle Css/Js across View Pages and Render it in the Master page? I thought I could use a ContentPlaceHolder above the Render portion, but there seems to be some odd behavior where it sometimes adds 3 files (1 in the view page and 2 in the master page) but other times will ignore the file added from the View Page.
Index.aspx
<asp:Content ContentPlaceHolderID="CssFiles" runat="server">
<% CssHelper.Add("home.css"); %>
</asp:Content>
Site.master
<asp:ContentPlaceHolder ID="CssFiles" runat="server" />
<% CssHelper.Add("reset.css"); %>
<% CssHelper.Add("master.css"); %>
<%=CssHelper.Render() %>
My current solution is a Static wrapper around SquishIt's static Bundle class that keeps the BundleBuilder in HttpContext.Current.Items.
I'm curious if this has been done successfully and how so.
Share edited Jul 2, 2010 at 15:58 dahlbyk 77.6k8 gold badges105 silver badges126 bronze badges asked Jul 2, 2010 at 15:31 Chris MissalChris Missal 6,1534 gold badges30 silver badges50 bronze badges2 Answers
Reset to default 12I think you might be missing the point of bundling css and javascript a little bit. If you are going to be adding in css or js files on each view, in bination with the master page files, then you are creating a ton of little bundles that your user has to download each time.
If you don't have a ton (and I mean a TON) of Javascript and Css, then you are better off bundling ALL of your css and javascript into the same bundle. This way the user takes the hit of downloading it the first time and then it gets cached.
If you have a TON of css and javascript, then use the named bundle feature and create bundles for different sections of your site. But the whole point is that you want to minimize the number of bundles that you create so that the user doesn't have to keep downloading files.
The only exception to this is for mobile browsers, where they have certain size caching limitations.
You could jump ship, and try Chirpy: http://chirpy.codeplex./
Or, you could modify the ZController approach to suit your fancy: http://www.weirdlover./2010/05/11/more-better-harder-zippy-cache-controller-in-asp-net-mvc/
I agree with Justin, though (and LOVE SquishIt as it is). You're probably better off creating fewer, larger bundles.
本文标签: aspnetCombining CSS and JS in Master Pages and View Pages With SquishItStack Overflow
版权声明:本文标题:asp.net - Combining CSS and JS in Master Pages and View Pages With SquishIt - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741665098a2391261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论