开发者

ASP.Net MVC: Centralizing CSS and JS dependencies

I'm using jQuery plugins in an ASP.Net MVC site.

I've often to include CSS and JS files as required by the plugins I use in every page. So I want to centralize all those dependencies in a single place in my app. thus if a dependency for a given plug-in is changed or updated, I'll only have to modify a single place in my app.

I've thought in two possible solutions:

  • Extend the HTMLHelper with a partial method like GetPlugin("jqgrid"); that will print out all the script and style tags needed.

  • Create a开发者_运维知识库 partial view for each pluginlike jqGridDependencies.ascx that will contain the script and style tags needed.

Do you have any other idea? what do you think of both proposals?


Could http://combres.codeplex.com/ provide you with a framework for this.

My only personal objection to this method is that each individual pages will have a unique JavaScript/CSS file where as if you combined and compressed everything into one and simply used classes and events to trigger the JavaScript enhancements as and when needed your site would run a lot faster.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜