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

  • Home
  • SEARCH
  • 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 3872480
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:55:49+00:00 2026-05-19T21:55:49+00:00

Just wondering about this… I have several separate javascript files, that all contain code

  • 0

Just wondering about this…

I have several separate javascript files, that all contain code based on the module pattern. A few of the modules have some of the others as dependencies. If i know that none of the code would be called on the HTML until the page is loaded, does the order in which the files load still important?

Is the fact that the module code sits inside an immediate function enough to trigger the requirement that the other modules be loaded already?

I am prepared to look into the RequireJS library if need be, but just wanted to know if what i am going is ok first.

  • 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-19T21:55:50+00:00Added an answer on May 19, 2026 at 9:55 pm

    If possible set up your dependencies so you can load and set up all your modules when the javascript file gets loaded (i.e. use a self executing function).

    And then call a .init or equivalent function on all your modules in a .ready block. That way you can explicitly call any functionality requiring dependencies after all your files have loaded.

    An example:

    foo.js
    (function() { 
        function initFoo() { ... }
        ...
        window.namespace.foo = {
             init: initFoo
        }
    }());
    
    bar.js
    (function() { 
        function initBar() { ... }
        ...
        window.namespace.bar = {
             bar: initBar
        }
    }());
    
    main.js
    (function() {
         $.ready(function() {
              window.namespace.foo.init();
              window.namespace.bar.bar(); // dependancies on foo
         });
    
    }());
    

    Any code that doesnt have dependancies can be executed in the closures of foo.js & bar.js and any dependant code can be called through your init function on .ready once all the files have loaded.

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

Sidebar

Related Questions

I use log4net in just about every code project. I was wondering what other
Just wondering what little scripts/programs people here have written that helps one with his
I'm just wondering about large projects - say an airlines reservation system, how many
Just wondering how you would go about implementing something similar to stackoverflow'd related questions.
Just wondering if a .NET app can be compiled down to native machine code
Just wondering where is best to put functionality in an MFC application that is
just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview
Just wondering if there is an easy way to add the functionality to duplicate
Just wondering why people like case sensitivity in a programming language? I'm not trying
Just wondering what the difference between BeginInvoke() and Invoke() are? Mainly what each one

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.