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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:57:55+00:00 2026-05-27T13:57:55+00:00

I’m a bit confused at the moment regarding how to have a more maintainable

  • 0

I’m a bit confused at the moment regarding how to have a more maintainable javascript architecture. I might be out of the track, but I would say that almost 50% of my code involves the DOM hence use my base library (jQuery).

I’ve checked [1] Nicholas Zakas’ scalable application architecture design: http://developer.yahoo.com/yui/theater/video.php?v=zakas-architecture and [2] Addy Osmani Patterns For Large-Scale JavaScript Application Architecture http://addyosmani.com/largescalejavascript/ .

I have a one page application style, with lots of content being fetched via ajax and DOM elements being added dynamically. My main question is: How can I separate the code into small re-usable blocks if I’m using jQuery (or any other base library) to manipulate the DOM.

Let’s just pick a task list module for example. I understand that the module could look like this:

var TaskList = function() {
  addTask = function() {
    ...
  };

  removeTask = function() {
    ...
  };

  return {
    addTask: addTask,
    removeTask: removeTask
  }
}();

Where should the DOM elements events registration be written, the ajax call to save, load, or delete a task, appending a new task to a DOM element, etc.

I have no problem committing to having jQuery on the module as a dependency, but if there is a better way I think I missed it from the two resources above and I would love to know it.

I just want to have a more elegant way of maintaining the growing javascript because I’m tired of spaghetti 😉

Thanks for your time!

  • 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-27T13:57:56+00:00Added an answer on May 27, 2026 at 1:57 pm

    Since you are going to develop a single page application you are going to have many visual modules that will be displayed at a current step and then they will be replaced by others.

    You can follow the MVC pattern (Model-Controller-View), with each visual element being a separate entity with its own code for DOM manipulation and the business logic stored in separate classes.

    One way would be:

    <html>
      <head>
       ....
      </head>
      <body>
        <div id="content"> 
        <!--The main container view that can handle the replacement of smaller views -->
          <div id="toolbar"_container">
            <!-- container for menu bar or tool bar that can also has its contained 
                 sub-views replaced -->
          </div>
          <div id="main_content_container">
            ....
          </div>
          <div id="properties_panel">
           .....
          </div>
        </div>      
      </body>
    </html>
    

    The main container can hold all the smaller container, with everyone accommodating a different view controller that has it’s own DOM manipulation code, (which also has the benefit of being able to be loaded dynamically on demand and so reduce your initialize load time).

    Every view can have a couple module that will perform the ‘actions’ and which will communicate with a third module (optional) that will take care of the I/O with databases, sockets, files, etc.

    Hope it helped!

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.