Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to include jQuery, Underscore, and Backbone as AMD modules using require.js?

I've seen many variations to loading modules which do not support AMD yet, and I would like to know what is the best practice to do so.

Eventually, I would like to write modules like this:

module.js:

define(["jQuery", "Underscore", "Backbone"], function($, _, Backbone) {
    ... module code here
}

But there are a lot of problems with loading those dependencies using AMD since they are not all AMD compliant.

like image 935
Ron Reiter Avatar asked Dec 26 '11 08:12

Ron Reiter


2 Answers

I've created a todo-list boilerplate web app which loads all modules as AMD modules (without loaders).

Check it out:

https://github.com/ronreiter/webapp-boilerplate

like image 164
Ron Reiter Avatar answered Oct 31 '22 23:10

Ron Reiter


Thomas Davis has a better example (imo) for loading jquery/underscore/backbone in his non-updated example. Start by looking at the loader here

It uses the RequireJS order plugin found here to load the modules synchronously.

like image 23
Matt S Avatar answered Nov 01 '22 00:11

Matt S