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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:14:17+00:00 2026-06-07T17:14:17+00:00

What is the use of a module loader? How it can be use in

  • 0

What is the use of a module loader? How it can be use in JQuery?
How to use require.js as module loader.
Please share the sample application too. if you have!!

  • 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-07T17:14:19+00:00Added an answer on June 7, 2026 at 5:14 pm

    Ok I go in parts

    What is a module loader?

    OK In Js you can’t use a import instruction (well yes in node you can.) so many people stick their code all together (even the librarys their using) so they don’t have to load anything, but this can bring large js files and add load time to your app, other people think that they separate the code and use the tag to load by pieces but this is unpractical as you have to maintain all definitions in the html pages, so here is were require.js comes and help you to decopule your code by creating modules and load then on demand. this make easy to separate your code and have small pieces easier to fix, maintain or add features.

    from require.js docs

    “When a project reaches a certain size, managing the script modules for a project starts to get tricky. You need to be sure to sequence the scripts in the right order, and you need to start seriously thinking about combining scripts together into a bundle for deployment, so that only one or a very small number of requests are made to load the scripts.”

    How it can be use in JQuery?

    I will change the question to How it can be use with JQuery?

    You will load Jquery as an dependency when is need it you have a basic example here

    How to use require.js as module loader?

    here a little snippet of code

    the html need it

      <!DOCTYPE html>
      <html>
        <head>
              <title>jQuery+RequireJS Sample Page</title>
            <script data-main="scripts/main" src="scripts/require-jquery.js"></script>
          </head>
          <body>
              <h1>jQuery+RequireJS Sample Page</h1>
         </body>
        </html>
    

    Our main.js

    require(["jquery", "jquery.alpha", "jquery.beta"], function($) {
        //the jquery.alpha.js and jquery.beta.js plugins have been loaded.
        $(function() {
            $('body').alpha().beta();
        });
    });
    

    part of the config

    paths: {
            "jquery": "require-jquery"
        },
    
        modules: [
            {
                name: "main",
                exclude: ["jquery"]
            }
    

    I hope this can help you. You can download an example project here

    I will add an example of my app so you can see how use Backbone and require

    the config

    require.config({
        shim: {
          'underscore': {
            deps: ['jquery'], //dependencies
            exports: '_' //the exported symbol
          },
          backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
          }
        }
    
        paths: {
          jquery: 'libs/jquery/jquery-1.7.1.min',
          underscore: 'libs/underscore/underscore-min',
          backbone: 'libs/backbone/backbone-min',
    
        }
    
      });
    

    An example module

    define(['jquery', 'underscore', 'backbone'], function($, _, Backbone) {
        //Your code Here
      });
    

    Have fun working with require 🙂

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

Sidebar

Related Questions

I have 2 perl modules every module use the second one i.e Module1.pm use
Currently I have a static class that I use as my logging module. I’ve
I have uncomment in module loader to load auth, but what I am not
I would like to use the Mail module of Zend Framework. I have extracted
I have a web application that use Sring IoC framework. I use the Java
The application is too big to describe here, but I can tell you I
I have a use case where my GWT application is running on a client
I use Module Autoloader to autoload resources (forms, Doctrine models etc.). I do not
I wanted to use winreg module of python for working with windows registry. But
I want to use a module as a singleton referenced in other modules. It

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.