RequireJS is inconsistent

When I press F5 to restart, the application sometimes throws errors, and sometimes not.

I am debugging Chrome. Sometimes the console reports this error:

Uncaught ReferenceError: unit_directionals is not defined

sometimes it shows that the link is not defined, as in this case for jquery: "Uncaught ReferenceError: jQuery is not defined"

What could be wrong if I defined the files correctly?

this is the code i have in main.js specified in the main html index:

requirejs.config({
    baseUrl: 'js/lib',
    paths:{
        app:'../app',
        models: '../app/models',
        views: '../app/views'
    }
})

requirejs(
    [
        //load lib in this order
        'underscore', 'handlebars', 'jquery','backbone', 'uri',
        //load models, views...
        'app/models/items.model', 'app/models/results.model',
        'app/views/items.view', 'app/views/results.view',
        'app/index'
    ],
    function(jQuery,$,_....) {
        //init app
    }
);
+5
source share
1 answer

requirejs loads async modules, and they may fail - they are not guaranteed to load in the order specified in the request. If the script is an AMD module and calls define () with its dependencies, this is not a problem.

, script , , , , shim config .

+10

All Articles