Module pattern- How to split the code for one module into different js files?

前端 未结 4 1550
礼貌的吻别
礼貌的吻别 2020-12-23 12:47

For the module pattern, I\'m doing something like:

(function(namespace) {
    // tons of code
    // blabla
})(window.myGlobalNamespace);

H

4条回答
  •  我在风中等你
    2020-12-23 13:32

    It sounds like what you're after is Require JS. I use this in almost all of my builds now. Alternatively you can have a look at the revealing module pattern as a fallback but for what you're after it sounds like Require is much more suitable.

    http://requirejs.org

    A good read: http://net.tutsplus.com/tutorials/javascript-ajax/principles-of-maintainable-javascript/

提交回复
热议问题