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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:15:30+00:00 2026-06-15T23:15:30+00:00

While loading CommonJS modules, we use require statement, which is synchronous. But doesn’t loading

  • 0

While loading CommonJS modules, we use require statement, which is synchronous.
But doesn’t loading modules involve reading them off the disk and interpreting them. So in a setup where we are advocating non blocking I/O how come require is synchronous ?

Update:

I have seen and used requireJS in the client and can appreciate its asynchronous nature. What I would like to know is that why doing something of this sort in the server is not widespread (I know requireJS can be used in Node but that is not the point).

Also I would like to know if requiring a module inline in my code makes my code blocking and if this is a bad practice and should be avoided.

  • 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-15T23:15:31+00:00Added an answer on June 15, 2026 at 11:15 pm

    requireing modules is generally something you do at the beginning of your program. If you don’t do it at the beginning of your program, the results are cached anyways. Starting a program like this:

    var fs = require('fs');
    var http = require('http');
    var oranges = require('oranges');
    
    // Do stuff
    

    Would work the same as starting one like this:

    require('async', function(err, async) {
        async.map(['fs', 'http', 'oranges'], function(err, modules) {
            var fs = modules[0], http = modules[1], oranges = modules[2];
    
            // Do stuff
        });
    });
    

    The difference is that one of them is needlessly complicated. Yes, there could be some kind of syntactic sugar implemented, but it still wouldn’t have any benefit, except in maybe some tiny edge cases.

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

Sidebar

Related Questions

I want to use an ajax loader while loading the page with transparent background.
I have a webpage which lags while loading, because an embedded object is trying
I am loading http url's successfully in UIWebView , but while loading https url's
I'm reading through the optimizer documentation for quite a while, but it seems like
I have backup folder where I store the images while loading them. So I
While loading a page, I want to get the top of the panel. But
While loading a Windows Form (C#), I'm trying to iterate through all controls. So
while loading getfptex(got it from CTAN) batch file ,when i'm extracting this batch file
While loading an XML file in SSIS using an XML source component , i
issue facing while loading the messages in to mq channel, recieving an error like

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.