Javascript code in ASP.NET MVC Partial Views (ASCX) or not?
- by Alex
Is there a "best practice" for placing Javascript code when you have many partial views and JS code that's specific to them?
I feel like I'm creating a maintenance nightmare by having many partial views and then a bunch of independent Javascript files for them which need to be synced up when there is a partial view change. It appears, for maintenance purposes, better to me to put the JS code with the partial view. But then I'm violating generally accepted practices that all JS code should be at the bottom of the page and not mixed in, and also I'd end up with multiple references to the same JS file (as I'd include a reference in each ASCX for intellisense purposes).
Does anyone have a better idea? Thank you!