Ismael
Ismael

Reputation: 2330

How to handle Dependency Management with javascript files using MVC?

I would like to know a good approach to develop a growing web application which consist in a large set of javascript files, depending on the screen.

I've searched without success...

In this site, i have some solutions: http://addyosmani.com/blog/large-scale-jquery/

I got the RequireJs as a good start point.

But... to the point... I'd like a feature where can be found in the php framework called Yii.

Its way to handle a bunch JS files is very simple. I tell to the framework, which file i need in a specific View, or Partial. The framework renders to me without duplicatin any include script tag.

Is there any feature like that in ASP.MVC framework? Or anything like that? I think i could do this making a Helper, don't know if it is a good way to handle thousands and thousands screen with plus thousand javascripts.

Upvotes: 1

Views: 411

Answers (1)

Lee Smith
Lee Smith

Reputation: 6737

Telerik use a HtmlHelper extension to do this:

    <%:Html.Telerik().ScriptRegistrar().DefaultGroup(
         grp => grp.Add("telerik.common.min.js").Add("telerik.draganddrop.min.js")
                    .Add("telerik.window.min.js")).jQuery(false).Globalization(true)%> 

<%

but obvioulsy you're not going to get intellisence if you do this.

Upvotes: 1

Related Questions