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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:29:15+00:00 2026-06-17T06:29:15+00:00

In a project I am maintaining, I am forced to stick with 2 jQuery

  • 0

In a project I am maintaining, I am forced to stick with 2 jQuery lib calls in one page (for now at least):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> /* 1st jQuery call */
<script>
    /* Section A - Some code that uses jQuery */
</script>

<script data-main="main" src="require.min.js">
     /* 2nd jQuery call made inside */
</script>

<script>
    /* Section B - Some code that uses jQuery */
</script>

This has been causing some weirdness in Section B that I’ve verified the source of the issue being the repeated inclusion of the jQuery lib.

Suppose I only have control over the AMD section – what’s the best/recommended option(s) I’ve got to handle this situation? Thanks!

  • 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-17T06:29:17+00:00Added an answer on June 17, 2026 at 6:29 am

    jQuery is an AMD module. Not only that, it’s a named AMD module, which makes it super difficult to use 2 versions of jQuery on the same page. (see this http://dvdotsenko.blogspot.com/2011/12/amd-modules-with-named-defines-so-much.html)

    However, in your case you don’t need 2 different versions of jQuery. You just need to use jQuery once outside of AMD and then inside of AMD code tree.

    Your solution is very simple: load require.js BEFORE you load jQuery. (Translation: put the script tag that loads RequireJS before the script tag that loads jQuery.

    <script src="require.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script>
        /* Section A - Some code that uses gloabl jQuery */
    </script>
    <script>
        // start the AMD code tree
        require(['main'],function(main){
            // run code that main module returns.
            // Don't know what that may mean in your case.
            // example:
            main()
        })
    </script>
    

    What happens there:

    1. requirejs loads and sets up global require and define objects
    2. jQuery loads and it (a) always sets global window.jQuery (+ window.$) and (b) if define exists and it’s of AMD variety, it defines itself as named module with specific name – “jquery” <- exactly that.
    3. Your code depending on global jQuery runs.
    4. Your code depending on AMD-registered jQuery runs.

    3 and 4 use one and the same exact instance of jQuery.

    You absolutely must require jQuery as “jquery” No other string will give you a jQuery instance.

    The only way you can alias jQuery is by creating a separate named define that repackages already-defined ‘jquery’ module:

    define(
      'my_jquery_yey'
      , ['jquery']
      , function($){return $}
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently maintaining a project I've inherited from some one else and the SVN
I'm maintaining an MFC/COM/ATL 45-odd project solution originally written with VS6. I'm now using
Right now we are maintaining some old project written in VB6 we are planning
I recently inherited a python project, and I'm working on maintaining it now. Part
Right now I've been maintaining a second sandbox project where I test concepts and
Recently I'm maintaining a legacy project. I found one javascript dead loop problem in
One project I'm working on involves continuously maintaining a base Linux disk image that
I'm maintaining a build script that calls devenv or Incredibuild from the command line
m maintaining a project, that has to be compatible through PHP 4.X to 5.2.
I'm maintaining a multi-project solution in ASP.NET + C#. We've decided to upgrade to

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.