Everyone knows scripts should be placed at the bottom of the page.
If you have a partial view in MVC, it may be necessary to render scripts specific to this view, and a common approach is to include the scripts (not necessarily inline) in the html mark up of the view.
The problem with this is that you may be depending on library scripts which are not loaded yet because they are the last thing in your Layout/Master.
One option is to change the design so that rather than calling Html.Partial to render a partial view, the partial view becomes the view, and the view becomes a master/layout. You can now use DefineSection, RenderBody, RenderSection etc. This however was not an option for me for several reasons.
Here is the solution I came up with which will only work for rendering content at the end of the document. It won’t…
View original post 167 more words