javascript - Backbone-RequireJs boilerplate for component based large web-projects -
we have large web project, need components can talk each other can put in central repository of components different projects. using reuirejs , backbone modular development. went through different boilerplate available backbone , requirejs, none matched requirement. have created following directory structure. can explained follows.
---resources |---custom-components |---mycomponent |---js |---views |---models |---collections |---css |---templates |---mycomponent.js |---mycomponent2 |---js |---views |---models |---collections |---css |---templates |---mycomponent2.js |---libraries |---backbone |---underscore |---jquery |---jquery-ui |---jqueryplugins |---jcarouselite |---thirdpartyplugins |---page-js |---mypage.js |---mypage2.js - resources directory contain resources. under have 4 directories mentioned.
- libraries, jqueryplugins , thirdpartyplugins obviusly directories name say.
- page-js directory contain actual main-js used inside our html file requirejs data-main attribute.
- custom-component widgets created reside, can see has js file same name of component, entry point of widget. directory has directories js, css , templates. css , templates loaded text plugin , css plugin respectively. js directory contain backbone code make widget work.
custom components asked main-js residing in page-js.
coming need.
1. want experts have review directory structure in perspective of large web projects, need share widgets other teams. suggestions welcome.
2. each custom-component define module, have dependencies within package structure outside package structure. want know, if there way use r.js optimize custom widget dependency within package structure , let plugins , libraries optimized separately.
3. developing single page ajax application, asking modules on demand need cleanup modules , widgets when dont need them, there way cleaning should aware of?
about directory structure
as directory structure pattern, highly recommend using directory structure of cakephp. it's robust in words!! i'm running multiple apps (one of them big groupon) , works charm.
may need tweak little because, know, cake php framework , yours javascript one.
here cake's awesome mvc directory structure:

please note may host thousands of apps on single cake installation. if you're interested, waiting for? go site , read docs.
about cleaning techniques
well, here 1 of downsides of javascript don't like. there no real way destroy oo module in java or c++. here don't have such things c++'s ~ destructors.
for many years, programmers use module = null free memory un-used codes.
take @ these also:
- can dynamically loaded javascript unloaded?
- loading/unloading javascript dynamically
- how unload javascript html?
hope helps , luck on designing app ;d
Comments
Post a Comment