Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Configure require.js to load vendor libraries without `vendor/` prefix #3

claymation opened this Issue · 1 comment

2 participants


Thanks for putting this together, it's a convenient reference. When building a library that requires third-party code (e.g., jquery), the temptation is to download the requirements into the vendor directory, and load them with: define(['vendor/jquery']). The trouble with this is that any other module that requires simply jquery will cause jquery to be loaded twice or referred to by two different module ids.

Alternatively, you can configure the require.js baseUrl like so:

  var require = {
    baseUrl: "../vendor",
    paths: {
      "skeleton": "../lib/skeleton",
      "cs": "../vendor/cs",
      "coffee-script": "../vendor/coffee-script"

so that modules (yours and third-party code) can simply: define(['jquery']). I'm curious if that's a good approach, and if so, if you would make this change in the test runners and the AMD demo harness?



Glad you're finding the repo helpful! You can set the baseUrl to ../vendor if you like, but I would simply add "jquery": "../vendor/jquery" to the paths key if it were my project. That will also allow you to use define(['jquery']), with the added benefit of not requiring every dependency in ./lib (presumably, where most of your code is going to be residing) to be define(['../lib/dep']). Make sense?

@tkellen tkellen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.