Reputation: 4483
I've been toying with the idea of rebuilding a very antiquated in-house CMS using backbone.js so that I build more of an app than a website. So far I'm comfortable with backbone and I've added in require.js to break the application into modules but there's one small thing that's bothering me.
My impression of backbone is that it would be possible to deliver the application to the user in a single initial payload but since adding require.js all models, collections, views, and templates are fetched individually on an ad-hoc basis.
Is it possible to break my application into modular payloads? For instance if the user enters the news section of the CMS they are delivered all the views, models etc. required for that module? The only solution I can think of is wrapping all the pieces of a module in a single define function call but this seems to break the paradigm of uncoupling the pieces of the application as a whole.
Any suggestions?
Upvotes: 1
Views: 224
Reputation: 4483
I think I've figured this out for myself. It looks like it's possible to use r.js (http://requirejs.org/docs/download.html#rjs) to compile modules into a single script which is exactly what I need.
Upvotes: 0
Reputation: 4721
Short answer:
try using requirejs modules
Long answer:
Check this out
https://github.com/ravihamsa/base-example/
I made an boiler-plate using requirejs, I call every module as an app, you can compile one JS file per module, and coupled with coupled with
https://github.com/ravihamsa/baseapp/
you can load each module on demand. But you got to follow the url pattern I do follow. like
http://yourapp.com/#appId/pageId/param1=value1;param2=value2
Whole app architecture is work in progress but you get enough insights
Upvotes: 1