Which Script downloader (AMD or not) to use with Backbone.js / Underscore?

Over the course of a week, I began to learn how to use require.js with Backbone.js and Underscore.js .

This is really complicated stuff, but 3 days ago I read that Underscore will no longer support Require.js (AMD) ! Now I'm a little confused.

I really like the Script Loader Concept and don't want to miss it!

Has anyone already successfully used the Script loader with Backbone.js (0.5.3) and Underscore (1.3.0)?

Thanks for the help!

Link: another solution here

+6
source share
6 answers

I found a solution that really works for me: Tim Brian

define([ 'jquery', 'use!underscore', 'use!backbone', 

I use it to add jquery plugin, custom js, underline and trunk (without changing the code!) ... but it seems to have a problem with jQuery mobile ...

you can also take a look at wrap , i haven't tested it yet!

0
source

I am currently using underscore 1.3 and Backbone 0.5.3 in my base boiler. You can see what I'm doing there:

https://github.com/tbranyen/backbone-boilerplate

+4
source

you can still underline with require.js, even if it doesn't support the AMD module style.

you can still download it as a regular external javascript source through a proxy module.

Its essence is in this code fragment:

 // Filename: libs/underscore/underscore // Loads the original underscore file from the libs/underscore folder define(['order!libs/underscore/underscore-min'], function(){ // Tell Require.js that this module returns a reference to Underscore return _; }); 

A complete tutorial can be found here: http://backbonetutorials.com/organizing-backbone-using-modules/

+2
source

I have a few here ...

https://github.com/jcreamer898/RequireJS-Backbone-Starter
https://github.com/jcreamer898/Savefavs

UPDATE July 7/08/2012

The latest version of RequireJS allows NON-AMD compatible libraries with the following code.

 require.config({ 'paths': { "underscore": "libs/underscore-min", "backbone": "libs/backbone-min" }, 'shim': { backbone: { 'deps': ['jquery', 'underscore'], 'exports': 'Backbone' } } }); 
+1
source

Require.js is the best alternative, in my opinion, since it includes an optimizer (minimization and concatenation) and allows you to disable your base code in modules.

If you are confused about how to integrate Require.js with the latest versions of Backbone.js and Underscore.js, check out the code for the template I created on github. Keep in mind that I'm using John-David Dalton's lodash instead of underlining because lodash provides better performance and a custom build process. I also use the Shim configuration that Require.js 2.0 provides for creating AMD-compatible scripts such as Backbone, AMD / Require.js.

https://github.com/gfranko/Backbone-Require-Boilerplate

+1
source

Have you tried labjs or headjs?

http://labjs.com/

http://headjs.com

Ah, that's yepnope too!

http://yepnopejs.com/

0
source

Source: https://habr.com/ru/post/905988/


All Articles