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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:37:17+00:00 2026-06-15T05:37:17+00:00

I have been working on a javascript application for a long time now, it

  • 0

I have been working on a javascript application for a long time now, it started out quite small and I was the only one working on it. However, it’s getting quite large. I would like to bring in another developer to speed up the work.

The problem is, this application consists of just one js file (15000 lines of code), working together on this app in the current situation would bring me a lot of misery when merging our work (I’m using git).

The app is built on Douglas Crockford’s base2 library. It also uses jQuery for DOM manipulation, jQuery UI, Modernizr and a few others.

It’s structured like this:

App = {};
App.model = {};
App.view = {};
App.controller = {};

App.main = base2.Base.extend({
    // uses models, views, controllers
});

App.model.AbstractModel = base2.Base.extend({
    constructor: function(){ ... },
    someMethod: function(){ ... }
    // etc.
});

App.model.AModel = App.model.AbstractModel.extend({
    // override some method
    someMethod: function(){ ... }
});

Now my question is, as the title states: (how) can I use RequireJS to make this app modular, consisting of separate files, with the eye on easier cooperation with other developers? Is RequireJS a good choice or should I go down a different path?

  • 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-15T05:37:20+00:00Added an answer on June 15, 2026 at 5:37 am

    Yes, I think that’s a good path to choose, it will improve the quality and maintainability of your code.

    1. you split the modules into separate files
    2. for each of the modules you figure out what are the dependencies among other modules
    3. you change the code in modules something like the following

    From

    App.model.AModel = App.model.AbstractModel.extend({
        // override some method
        someMethod: function(){ ... }
    });
    

    To

    // I'm using shortened syntax here 
    // http://requirejs.org/docs/api.html#modulenotes
    define(function (require) {
      // here you are listing dependencies as local closure variables
      var AbstractModel = require('model/AbstractModel');
    
      var AModel = AbstractModel.extend({
        // override some method
        someMethod: function(){ ... }
      });
    
      // here you are returning the module
      return AModel;
    });
    

    As for dependencies like jQuery, at SoundCloud we decided to just include them minified and concatenated as globals (the way they work with regular script tags), without wrapping them in AMD module definitions.

    You will also probably have main app.js that will require all these modules and kick off the app:

    require(
      ['models/amodel', 'views/main'/*, 'more', 'modules', … */], 
      function (Amodel, Main /*, more, modules */) {
        new Main({
           model: Amodel
        });
      }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on facebook application and you know on facebook native javascript
I have been working on a large java application. It is quite parallel, and
So I have been working with javascript for a website I am designing, shocker
I have been working with SQL Server as a Developer a while. One thing
I have been working with Zend for a few months now and am at
I have been working on a small file manager module in a project where
I just started learning Backbone.js, and have been working on (what else) a simple
I am currently working on rails3 application that uses jQuery. I have a javascript
I have a javascript Windows Store application that I'm working on, and I needed
Recently I have been working on upgrading a big web application that was using

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.