mark smith
mark smith

Reputation: 20907

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

Upvotes: 3

Views: 896

Answers (3)

bahadir arslan
bahadir arslan

Reputation: 4782

I think Scripts folder is the best choice. Don't put them into Views folders, because when you want to use an existing script in a view folder; it became a nightmare.

Edit: I had a mistake and wrote Content folder. I corrected it now.

Upvotes: 0

Tim Rogers
Tim Rogers

Reputation: 21723

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.

Upvotes: 3

Łukasz W.
Łukasz W.

Reputation: 9755

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.

Upvotes: 3

Related Questions