Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:29:16+00:00 2026-06-11T15:29:16+00:00

I was wondering what’s best practice for a javascript file’s location that is view-specific.

  • 0

I was wondering what’s best practice for a javascript file’s location that is view-specific.
Some of my views have 1700+ lines of code, 70% of it being javascript, so I’m putting them into a .js file to take advantage of bundling/minifying.

I know core script files (eg. jquery) typically go into the root /Scripts folder, but there are a LOT of views that i need to do this to (50+), so I’m wondering if I should put them in their respective view folders (eg: /Views/Account/ViewName.js) or should i dump them all into the /Scripts folder at the root.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:29:17+00:00Added an answer on June 11, 2026 at 3:29 pm

    In my practices, I’ve basically made the following static assets structure:

    public
    -- css
    -- javascript
    ---- controllers
    ---- lib
    -- otherAssets
    

    And using some controller logic, I add a file per controller to /public/javascript/controllers so that way my controller specific code is all bundled together.

    You could just as easily rig it to be per model, and then have object oriented methods in your js files like this:

    myModel = {
        pageA: function() {
            //stuff
        },
        pageB: function() {
            //stuff
        }
    };
    

    doing it this way would mean that you’d need a parent javascript file that basically finds the proper javascript model object (i.e. myModel), then controller method (pageA) and then calls that function.

    Anything more complex than that really starts bringing you into the territory of you needing a javascript assets manager like require.js

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering if anyone can suggest a good file replication tool that will replicate across
wondering if some of you know what javascript framework facebook is using ? Thanks
Wondering what others do / best practice for communicating between layers. This question relates
Wondering if someone can answer something that has stumped me. I have a Timer
Wondering how to open many new windows with Javascript. I have found plenty of
Wondering is there a function in javascript without jquery or any framework that allows
wondering if there's any way to make it so that a list I have
Wondering what the best / good way of doing this would be in jQuery.
Wondering if any of you can help me: I've made a signup modal that
Wondering if someone could help me. I have next to no knowledge with Ajax,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.