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 6862009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:36:28+00:00 2026-05-27T02:36:28+00:00

Given that: The asset pipeline is fairly complex (coming from ASP.NET MVC, this is

  • 0

Given that:

  • The asset pipeline is fairly complex (coming from ASP.NET MVC, this
    is much more complex):
    How do I associate a CoffeeScript file with a view?
  • All the js files will be loaded on each page and every “on ready”
    jquery method in each file will be executed

Does it make more sense to break the javascript for an application into “areas” — one js file for the user/public area of a site, one file for the admin area of a site and so on. Scripts coming from external sites (jquery, other sites in the org) wouldn’t really apply.

The upsides I see are

  • Performance: loading one 80kb file is much faster than loading 4 20kb files because of TCP/IP overhead (source). In production, all of the public js will be compiled into one file and served on every request, but I see downsides to including “admin” code in that file.

  • Security: there might be some things in script files that I don’t want to expose to unauthorized users. Granted, if it’s in script it’s not secure, but it would be nice if I could minimize the exposure of things like paths to controller actions that perform database maintenance.

  • Simplicity in development: if the on-ready event will be firing off from each file, it makes sense to me to just put it in one file, that way I won’t have to load each file to see what on-readys are in there. The js for sub-areas (like admin) would naturally be in a separate file that wouldn’t come from assets

Related: Put javascript in one .js file or break it out into multiple .js files?

  • 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-05-27T02:36:29+00:00Added an answer on May 27, 2026 at 2:36 am

    Splitting admin javascript from other javascript sounds like a good idea.

    That performance article is definetly right. I haven’t seen a situation where caching as much javascript in one file hasn’t been the performance winner. Even if the areas don’t share javascript, downloading a larger file all at once tends to be faster than multiple downloads.

    If you have a lot of libraries and 1-off page specific javascript files then maybe caching all the libraries makes sense, just make sure you measure for cache hits for a typical user when testing.

    There are patterns you can use to minimize the onload problem. Splitting things into modules and only initializing those modules based on feature detection has been an effective method for me.

    For example, if I have a UserInfo module:

    !function(ns) {
      ns.init = function() {
        ns.setup_login()
        ns.show_user_info()
      }
      ns.setup_login = function() { /* blah-blah */ }
      // ... etc
    }.call(this, this.UserInfo={})
    

    And if I have some html on the page related to a login:

    <div id="user_login">
      <div class="user_info"></div>
      <div class="login_links"></div>
    </div>
    

    I can write an initializer like:

    $(function() {
      $("#user_login").each(function() { UserInfo.init() })
    })
    

    Without this pattern I would’ve written loading calls to setup_login and show_user_info separately. Usually this lets me initialize a few different modules based on what aspects I detect on the page, and if you group these modules by their dependencies that usually cuts it down even more. (I might’ve done User.init -> UserInfo.init since maybe I could assume UserInfo depends on User.)

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

Sidebar

Related Questions

Given the code block below (source: http://www.asp.net/learn/mvc/tutorial-31-cs.aspx )... I receive this error: Using the
I have a controller action in ASP.NET MVC that handles uploaded files. However, it
Given that this field locale have been set for norwegian bokmål and norway: Locale
Given that indexing is so important as your data set increases in size, can
Given that Chrome and Safari use webkit has anyone yet found anything that renders
Given that a function a_method has been defined like def a_method(arg1, arg2): pass Starting
Given that I only have one monitor, what's the best way to debug a
Given that Decimal.MaxValue = 79228162514264337593543950335m Why does the next line give me 7922816251426433759354395034M in
Given that: SSD’s are now [high end] mainstream Two+ cores are not hard to
Given that there are many sizes and color depths for different phones (even for

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.