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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:33:59+00:00 2026-05-26T01:33:59+00:00

NOTE: I have now created a jQuery plugin which is my attempt of a

  • 0

NOTE: I have now created a jQuery plugin which is my attempt of a solution to this issue. I am sure that it could be improved and i’ve probably overlooked lots of use cases, so if anyone wants to give feedback feel free 🙂 https://github.com/WickyNilliams/ReadyBinder

I don’t have a problem as such, but thought this would be an interesting point for discussion, and i hope people have some interesting ideas for this.

Basically, i work on a large-scale website and increasingly we are writing more and more JavaScript. This is fine, i enjoy JS’ unique approach and i find the quirkiness in some of the darker annals of the language to be endearing 😉 However one thing that has always bugged me is how to manage document ready events as they get increasingly large over time (and as a result less focused/specific to the page being served)

The problem is that we have one JS file (merged & minified, though that’s kind of inconsequential for my questions). Most of the JS is written using the revealing module pattern, and jQuery is our framework of choice. So all our JS funcitonality is logically grouped into methods, namespaced, and then right at bottom of the script file we have this

$(function(){
    //lots of code here, usually calling encapsulated methods 
    //on our namespaced revealing module
});

The problem is that not all of the code in this document ready handler pertains to every page. For instance, on one page only 10% of it might be relevant, on another perhaps 80% might be relevant. To me, this feels incredibly wrong, i feel i should only execute the code i need per page, mainly for efficiency, but also maintainability.

I’ve searched google for approaches to this issue, but cannot find anything, maybe i’m just searching for the wrong thing!

Anyway, so my questions are:

  • Has anybody ever thought about this issue?
  • Is it actually an issue in other people’s opinion?
  • Do you have a large, all-encompassing document ready handler in your code or is it more focused for the type of page being served?
  • If the latter, how do you manage this? Multiple handlers which get switched in JS or dynamically spitting out the document ready handler server-side?

Look forward to people’s thoughts on the matter.

Cheers

  • 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-26T01:34:00+00:00Added an answer on May 26, 2026 at 1:34 am

    This is what i have done in my rails mvc project with heavy javascript, i have created a separate namespace for the controllers in js which resembles the rails controller

    class BusinessController
       def new
       end  
       def index
       end
    end
    

    and

    Var Business =  {
          init : function(action) {
             //code common to the Business module
             //even add the common jquery doc ready here, its clean
             //and call the page specific action
             this[action]();
          },
          new : function() {
                 // check jquery document ready code here, thats relevant to this action
                 //New rental page specific code here
          },
          index : function() {
                 //  check jquery document ready code here, thats relevant to this action
                 //index rental page specific code here 
          }
    }
    

    and on the view code(server side) just initiate the page specific js code by

    <script type="text/javascript"> 
     <%= controller_name %>.init('<%= controller.action_name %>'); 
    //which will render to
    //  Business.init(index);
    </script>
    

    You can pretty much tweak this to make it work in any language. And this approach doesn’t care whether you have a single file or multiple files.

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

Sidebar

Related Questions

Note that this function does not have a { and } body. Just a
Let's say I have a simple stored procedure that looks like this (note: this
I have to give a general note to some huge Java project for which
I have up to 4 files based on this structure (note the prefixes are
I have the VS2005 standard edition and MS says this: Note: The Windows Service
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
Note: This is the opposite direction to most similar questions! I have an iPhone
First as a note I am using this plugin in a Rails app. Ok
i have created folder on my server (ie finesse)- 'home' in which i have
I have a list that is created within an itertools.groupby operation: def yield_unpacked_list(): 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.