In my ASP.NET MVC4 web application, I will have many views in which the application functions as a single page application (SPA) within the view, but navigating to another view is done via traditional navigation. Each view/page is like its own SPA. So I want to deliver a viewmodel.js file specific for each page because I don't want to apply knockout bindings for all the views when I'm only looking at one of them.
My question is, should I create a separate bundle for each videmodel.js file, or can/should I somehow completely circumvent bundling for my view-specific scripts? What's the best way to circumvent the bundling?
I've tried simply appending
<script src="~/Scripts/app/inventory.viewmodel.js" type="text/javascript" />
to my Index.vbhtml file (my view), but it comes out above the rest of the scripts even though it's after the @Section Scripts
block. I tried including it in the @Section Scripts
block, but I can't figure out the right syntax to avoid using @Scripts.Render
.
Once again, my question is not only how to circumvent bundling but whether circumventing bundling is the best option here.
Edit I switched from the self-closing script tag to
<script src="~/Scripts/app/inventory.viewmodel.js" type="text/javascript"></script>
embedded in the @Section Scripts
block, and then it works, but I still wonder if this is advisable.