My main motivation for trying to do this is to get Javascript that is only required by a partial at the bottom of the page with the rest of the Javascript and not in the mid
The more elegant way to do this is to move partial view scripts into separate file and then render it in Scripts section of view:
This is the view
@Html.RenderPartial("_Partial")
@section Scripts
{
@Html.RenderPartial("_PartialScripts")
}
The partial view _Partial.cshtml:
This is the partial.
The partial view _PartialScripts.cshtml with scripts only: