Multiple HTML Pages vs Single Page with JavaScript – Which is Better?

csshtmljavascript

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?

Best Answer

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.

Related Topic