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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:00:12+00:00 2026-05-31T16:00:12+00:00

I want to do something very simple in javascript. I have a main.js file

  • 0

I want to do something very simple in javascript. I have a main.js file which needs to call a calculation method in math.js.

If I include in index.html these two files with script tag, first math.js and then main.js, am I garanteed that math.js will have finished loaded before I can use it in main.js ?

If not, would I need to do some overkilled hack like I read here How do I include a JavaScript file in another JavaScript file? or even worse because I can’t even see in that link how dependency is actually taken into account.

Update: Why can’t I do like what Dashcode seems to do How can I add my library to be loaded Dashcode parts ie just use document.write(‘…’)? Is in fact document.write robust enough on a very slow connection if the library was bigger than main.js ?

  • 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-31T16:00:13+00:00Added an answer on May 31, 2026 at 4:00 pm

    Set a variable in math.js and proove in main.js if this variable exist.

    var mathLoaded = true;
    

    in main.js:

    function loaded() {
        return ((typeof mathLoaded) !== 'undefined');
    }
    

    Edit:

    Now you can start an wait function, until it is loaded:

    function wait() {
        if(loaded()) {
            //doSomething();
        } else {
            window.setTimeout(function() { wait(); }, 0);
        }
    }
    
    window.setTimeout(function() { wait(); }, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP form that needs some very simple validation on submit. I'd
I am trying to do something very simple. I want to display an image
I want to have a very simple editor for my website that i wrote
I have just started looking at javascript so hopefully this will be something simple.
I have to do something very simple, but there doesn't seem to be an
Say you have a very simple data structure: (personId, name) ...and you want to
I have a simple HTML page on which I want to be able to
Hi I'm new to JavaScript and I want to code a very simple expanding
I am really struggling trying to get something very simple achieved. Essentially, I have
I want to do something quite simple. Click a button on my html javascript

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.