简体   繁体   中英

ASP.NET separate javascript directory structure

I am using ASP.Net with jquery/javascript. Common wisdom seems to dictate that the javascript for a page be in a separate file, I was wondering if anyone has suggestions for best practise as regards to where these js files should be placed in the website directory structure, as you may end up having a considerable amount of JS for each page, obviously library routines would be in a dedicated js directory. Does anyone have any suggestions? These are possibilities I was considering:

  • Js
    • Default.js
    • lib.js
  • App
    • Default.aspx
    • Default.aspx.cs

Or

  • Js
    • lib.js
  • App
    • Default.aspx
    • Default.aspx.cs
    • Default.js

What we do in our team is that we have duplicate directory structures for our .Net files and our .js files. It has served us pretty well and that way your Javascript code and .Net code is grouped together and is easy to find.

So I would vote for your first example as a "Best Practice"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM