2014年12月22日 星期一

[requireJS] Simple Dependecies

In requirejs, we can make use of the following codes to control the order of how js can be loaded.

var require = {
    shim : {
        "bootstrap" : { "deps" :['jquery'] }
    },
    paths: {
        "jquery" : "//code.jquery.com/jquery-2.1.1.min",
        "bootstrap" :  "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min"
    }
};

paths: Self-define js path as variables
shim: Define dependencies, in this case bootstrap REQUIRES jQuery

Remember, after defining this require variable, we still need to define/require the js files or the variable's definition is useless.

Reference:http://getfishtank.ca/blog/how-to-use-bootstrap-3-with-requirejs

沒有留言:

張貼留言