1

I have the following main.js

requirejs.config({
  baseUrl: 'js',
  paths: {
    "jquery": "http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"
  },
  shim: {
    'backbone': {
      deps: ['underscore', 'jquery'],
      exports: 'Backbone'
    },
    'marionette': {
      deps: ['jquery', 'underscore', 'backbone'],
      exports: 'Marionette'
    },
    'underscore': {
      exports: '_'
    }
  }

});

The code to require query:

define(['jquery', 'backbone', 'marionette'], function($, Backbone, Marionette) {

Backbone, marionette and underscore all load correctly, but requireJS is ignoring the 'paths' config and trying to load jquery from js/jquery.js, not the CDN.

Using requires 2.1.9

2
  • Can you show us the code that makes RequireJS load jQuery? (Either the define that lists jQuery as a requirement or the require that mentions jQuery.) Commented Nov 16, 2013 at 19:22
  • I have updated as requested Commented Nov 16, 2013 at 19:40

1 Answer 1

2

You should exclude the ".js" extension from the CDN URL, just as you would for file paths in your baseUrl directory:

paths: {
    "jquery": "http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min"
  },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.