2

Is it better to use multiple html pages and link them together with href or just change content on the same page using JavaScript? I am thinking of how to layout a page and I don't have a lot of content. It would probably be about three of for pages if I just used all html. If I toggled and swapped bits of html around using JavaScript, I could probably fit it all on one page, and it would be a bit "cooler", in that it's more of an application, dynamic, etc. But I'm just wondering what the best way to go here? Is it horrible to have to much JavaScript "squashed" to one document? How do you know where to draw the line when thinking about this?

7
  • Is it three different views of the same content (different filters, etc) or is it three different pages (like home, help, about us)?
    – Roman
    Jul 22, 2012 at 3:26
  • different content Jul 22, 2012 at 3:51
  • If it's logically different content it would make more sense for it to be on different pages.
    – Roman
    Jul 22, 2012 at 3:52
  • There is no objective 'better' in this context. Its purely a matter of your preference on how to display the information. Jul 22, 2012 at 3:57
  • If that's the case I will go with JavaScript, because it makes things all in the same place for the viewer, and doesn't have to navigate different pages. Jul 22, 2012 at 4:00

2 Answers 2

6

The downsides you need to consider if you go with the "all on one page, swapped using Javascript" approach:

  • Will people be able to bookmark or link to specific pages of information?
  • Will people be able to use their browser's back/forward buttons to navigate between pages on your site?
  • Will people with Javascript disabled (small but non-zero population) be able to use your site at all?
  • Will Google and other search engines be able to spider and index your content?

None of these problems are insurmountable, but they're all problems you won't have if you follow the traditional decades-old model of putting separate pieces of content on separate pages.

2
  • 2
    It is possible to fix all 4 problems with the javascript page.
    – Zachary K
    Jul 22, 2012 at 7:56
  • 2
    @ZacharyK: indeed, like I said, "None of these problems are insurmountable". Jul 23, 2012 at 0:25
2

A good maintainable approach or practice to follow would be using master page layout. While having separate content pages that are linked through your master page.

Here is a reference how to set it up, if you use pure HTML and CSS - Using a Master Page to create a 2 column CSS layout.

If you are using Visual Studio then you may also find it useful to look at the followings:

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.