0

I am building a simple project that has below modules.

  1. login page (HTML)
  2. Register Page(HTML)
  3. Main Page(HTML)

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.

1
  • Both are possible. What approach is best really depends on the specifics of your application. Commented Mar 10, 2014 at 16:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Simon for the answer, I have looked into AngularJS and so it looks good. Not sure what backbone is capable of, but reviews from other developers are good.
AngularJS is a good choice, it is gaining a lot of popularity and has improved a lot since its original conception. Note that for AngularJS you do not need Routie since Angular provides it's own routing implementation. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.