0

I'm creating a small web application. The application have several screens (list, inner list, item details, etc.). I have a REST API on the server and I need to create the client.

At start I thought about HTML page for each main screen. For every page I have a CSS and JS code. The HTML will include only place holders (empty divs) that wwill be filled by the JS code.

Then I've decided to a create the application as single page application and using the URL with anchors to imply the state (domain.com/#list1#item1).

I've found this question to be informative about the architecture of the application, but I wonder:

1) How can I server the right CSS to the page in a clean way?

2) How can I define the page basic structure (the way the HTML divs do) in a clean way?

Community
  • 1
  • 1
Roy Tsabari
  • 2,000
  • 6
  • 26
  • 41
  • I would add the single-page functionality as an extra. You can build your page with regular links and redirects but use JavaScript to intercept all of those requests and make the page act nicely. – Blender Feb 13 '12 at 18:51

1 Answers1

0

Unless your css is drastically different from one page to the next it should probably be in one page anyway. You will have a base css file that gets served up to every page and then page specific css files as needed for each pages. The idea is to reduce page loading overhead, but in your case it sounds like it is pretty small so putting everything in one css file shouldn't have too big of an impact.

As for page structure, start by just doing a rough drawing of each page on paper and then pencil in the divs. Then see how things overlap and what can be the master page layout elements and what are the actual page layout elements. then look at the common pieces to decide how to set up your divs.

To be honest, trying to do everything in one page, the layout of the divs is going to be a little bit messy at best. Unless it is related functionality like the steps of a wizard or something similar, putting it all in one page may cause down the road problems if you try to add or change things.

Brian
  • 2,229
  • 17
  • 24