Reputation: 2798
I am building a simple project that has below modules.
Since everything will be in modules,I have chosen requirejs for this task plus it's module loading capability.
I wanted to know, if there will be 3 html files in my project, will there be 3 data-main, I mean 3 main files that will have configuration.
Is there way to have a single main file or I need to have only one HTML file, that shows one functionality(i.e. login or register or main page) at a time. Which one will be a good approach or practice. I am new to requirejs. Thanks in Advance.
Upvotes: 0
Views: 86
Reputation: 422
If you are building a multi-page application then each page will need to load requirejs and have a data-main. The reason being is that going to a new page will no longer have the files loaded and will lose it's memory.
More common nowadays is to build a single-page application with hash routing. When using something like RequireJS it is often with this kind of app in mind. You can have one index.html file that will load templates based on what you're trying to display (login/register/main). A routing library like routie (http://projects.jga.me/routie/) and others will handle changing the hash in the address bar.
If you do take the single page application route, I would suggest using a framework like KnockoutJS, BackboneJS, AngularJS, Ember.js... Any of these will help with most of the heavy lifting.
Upvotes: 1