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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:47:54+00:00 2026-05-27T08:47:54+00:00

I have been building a single page app using requireJS and so far loving

  • 0

I have been building a single page app using requireJS and so far loving it. I have come to the point of developing other parts of the site outside of the main app and am not really sure how (or if) to use requireJS for this.

In my main app everything is triggered by this script tag:

<script data-main='/scripts/main' src='/scripts/libs/require.js'>

I am now developing the home page which has it’s own front end scripts. Using the optimizer when it comes to getting the site live which will bundle all these scripts into one main.js package. I am struggling to understand where the rest of my site fits into this.

Say my app is dependent on jQuery and it gets bundled up in the optimized version of the app, what if I want to use jQuery on the homepage? I don’t want to load in my app’s main.js just to get access to my jQuery module. So yeah… a little confused!

I am imagining a site structure sort of like this:

/scripts
  - app-main.js //(includes all module dependencies after optimzation)
  - home-main.js //(includes all module dependencies after optimzation)

App:

<script data-main='/scripts/app-main' src='/scripts/libs/require.js'>

Homepage:

<script data-main='/scripts/home-main' src='/scripts/libs/require.js'>

Questions

  1. How can I use RequireJS to develop different parts of a site?
  2. Is it recommended to have multiple main.js files?
  3. How can my different main.js files share common modules such as jQuery post optimization?
  • 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-27T08:47:54+00:00Added an answer on May 27, 2026 at 8:47 am

    So require.js should always be used on any page to allow for modularity and a clean namespace. I believe each ‘app’ needs it’s own main.js script. When optimizing your site r.js allows for you to exclude modules from the compilation which you should do for jQuery always.

    That way require.js will always load jquery.js on the fly and most of the time from the cache. Finding other modules that might be cached between your app and homepage will have to be done at your own discretion and depends on the flow of your users and other factors.

    It sounds like you have two projects, an app and a marketing site. I believe those should be separated to quite an extend and should have their own respective ‘js’ folders containing their own main.js.

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

Sidebar

Related Questions

I have been using SQL CE for a desktop app I am building but
I have been building a new application using my current understanding of domain driven
I have been investigating building web parts for sharepoint 2010 and currently have a
I have been using PHP and JavaScript for building my dad's website. He wants
I am building a web application and have been told that using object oriented
I have an ASP.NET MVC app that I have been building, and I am
I'm building a multilingual website. I've been thinking about using a single table for
I am building a single-page web application and I've been looking for a library
I have been building enterprise software for the last 10 years. In this time
I have been building IMO a really cool RIA. But its now close to

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.