I want to keep all of my JavaScript code in one section; just before the closing body
tag in my master layout page and just wondering the best to go about it, M
Modified version of Darin's answer to ensure ordering. Also works with CSS:
public static IHtmlString Resource(this HtmlHelper HtmlHelper, Func
You can add JS and CSS resources like this:
@Html.Resource(@, "js")
@Html.Resource(@, "css")
And render JS and CSS resources like this:
@Html.RenderResources("js")
@Html.RenderResources("css")
You could do a string check to see if it starts with script/link so you don't have to explicitly define what each resource is.