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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:18+00:00 2026-05-26T19:51:18+00:00

I am trying to load some JavaScript files inside another JavaScript file in the

  • 0

I am trying to load some JavaScript files inside another JavaScript file in the following case:

js/script1.js

var script_1_method = function () {
   console.log("Hello Script 1");
}

js/init-script.js

console.log("Initiating Scripts...");
loadScriptMethod('js/script1.js');
script_1_method();
console.log("Hello Script 2");

index.html

    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
      <meta charset="UTF-8">
      <title></title>
      <script type="text/javascript" src="js/init-script.js"></script>
    </head>
    <body>

    </body>
    </html>

The Console output should be

Initiating Scripts...
Hello Script 1
Hello Script 2

I have looked into many JavaScript loaders like curl.js, RequireJS, JSL almost all of them do an Asynchronous way of loading files requiring callbacks for my scenario.

Is there a library to load the scripts in a synchronous way as in the above case without requiring callbacks.

Please let me know if there are any JavaScript loader libraries which cater to the above case.

  • 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-26T19:51:18+00:00Added an answer on May 26, 2026 at 7:51 pm

    It’s possible to load same-origin scripts using a synchronous XHR:

    var scr = getViaSynchronousXHR('js/script1.js'),
        el  = document.createElement("script");
    
    el.appendChild(document.createTextNode(scr));
    document.documentElement.firstChild.appendChild(el);
    script_1_method();
    

    A script element without a source is parsed and executed synchronously, because there is no wait for the file to be downloaded/fetched from cache.

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

Sidebar

Related Questions

I'm trying to call a function after I load some XML into Actionscript, and
I'm currently trying to find a good way to load my javascript files only
I am currently trying to load some js files asynchronously, so that they are
So I'm trying to load some returned html from an .aspx page but a
I'm trying to load some stuff using AJAX when a user clicks a link,
I am trying to load some info from the database asynchronously. I have a
I'm trying to load some images using Bitmap.getBitmapResource() , but it takes about 2
In the NodeMouseClick event I'm trying to load some objects from the Node.Tag. Before
In the code below I'm trying to load some images and put them in
I'm trying to load page and then remove some elements in it. While doing

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.