Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 2: Where to put custom JS files?

what is the recommended place to put .js files - not really talking about jquery etc.... but my own custom js files..

The scripts directory seems to contain ajax, jquery etc... So is this the correct place?

OR would a better place be COntent?

I also was doing a search and saw some arguments for placing the JS files in the VIEWS directory - but is it supported?

Any ideas or comments really appeciated

Is there a document that outlines what each directory should be used for ?

I was thinking of placing my images like this Content/Images

Thanks again

like image 979
mark smith Avatar asked Nov 25 '25 18:11

mark smith


2 Answers

I think that as far as .js files are scripts, then you should put them into Scripts folder. If you are worried about mixing your own scripts with jquery and all that microsoft stuff, then just put them into separate subfolders.

like image 87
Łukasz W. Avatar answered Nov 28 '25 06:11

Łukasz W.


You'd only want them in the Views directory if you were dynamically creating scripts based on data from the controller. This approach isn't great - you should try and separate Javascript from Html.

Otherwise, Scripts is the best place for them.

like image 35
Tim Rogers Avatar answered Nov 28 '25 08:11

Tim Rogers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!