requireJS : How to structure Javascript for an entire site?

Posted by pagewil on Stack Overflow See other posts from Stack Overflow or by pagewil
Published on 2011-02-28T13:39:10Z Indexed on 2011/03/20 0:09 UTC
Read the original article Hit count: 178

Filed under:
|
|

I have 3000+ lines of javascript that I need to get into a sensible/maintainable structure. I have chosen to use requireJS as it has been recommend to me by a few people. I have a bunch of variables that are used throughout the application and need to be available everywhere. I also have a bunch of functions that need to be available everywhere. Apart from these two dependencies most of the code can be divided off into their own modules.

I am having trouble understanding how to manage my main variables so that if one module of code makes changes to the variables the rest of the JS modules will see that change. I think I need to see a few examples that demonstrate how requireJS is intended to work on a larger scale that the examples in the documentation.

If anyone is an experienced requireJS user I would love the hear your tips!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about module