Approaches to modular client-side Javascript without namespace pollution

后端 未结 8 1374
借酒劲吻你
借酒劲吻你 2021-02-02 02:14

I\'m writing client-side code and would like to write multiple, modular JS files that can interact while preventing global namespace pollution.

index.html



        
8条回答
  •  生来不讨喜
    2021-02-02 02:44

    http://brunch.io/ should be one of the simplest ways if you want to write node-like modular code in your browser without async AMD hell. With it, you’re also able to require() your templates etc, not just JS files.

    There are a lot of skeletons (base applications) which you can use with it and it’s quite mature.

    Check the example application https://github.com/paulmillr/ostio to see some structure. As you may notice, it’s written in coffeescript, but if you want to write in js, you can — brunch doesn’t care about langs.

提交回复
热议问题