How to ensure that modules wait for require.js dependencies to load?

I have about 3 different errors that can occur when loading the same page. I get different errors when I refresh the same page: jquery ui loads before jquery, or underline does not load in time to be dependent. Is there a way to make sure that the configuration modules wait for their downloaded files to load before loading? I am using the following:

main.js

require.config({ paths: { jQuery: 'libs/jquery/jquery-wrapper', Underscore: 'libs/underscore/underscore-wrapper', Backbone: 'libs/backbone/backbone-wrapper', } }); require([ 'src/app', 'order!libs/jquery/jquery-min', 'order!libs/jquery/jquery-ui-min', 'order!libs/jquery/jquery.ui.selectmenu', 'order!libs/underscore/underscore-min', 'order!libs/backbone/backbone-min', ], function (App) { App.initialize(); }); 

I am taking nested dependencies from the page. app.js

 define([ 'jQuery', 'src/global' ], function ($) { var initialize = function () { var d = $('#dependencies').html(); require($.trim($('#dependencies').html().toString()).split(','), function () { }); } return { initialize: initialize }; 

});

+4
source share
2 answers

I switched to Require 2.0 and used a gasket, which works for the most part.

0
source

I used Require v2, which got rid of order. I switched to version 1 and the problem was resolved.

0
source

All Articles