Is it OK to put JavaScript in Partial Views

If Resharper warns you it’s not a big deal ^_^

But if I were you I wouldn’t put JavaScript in the partial view at all.

Because the partial view could be inserted in one page many times then you’ll get an issues with your JavaScripts.

And for your case if you couldn’t separate the JavaScript to JS file then just create another PartialView and put these scripts in it and just render it in your main page.

Leave a Comment