I am working on a highly dynamic site which has around 10 different pages (login, registration, my services, my profile, etc.).
I am thinking of using a javascript template framework (e.g., jquery-temp) and store all the pages in one single html file. User interactions will trigger swapping/activating/hiding of different templates. On the server side, all the request are managed through rest/json calls. I am thinking that the html will be served by nginx while the json calls are directed to jetty (java).
Is this a viable approach and what can go wrong ?
Thanks,
EDIT - I know how to do this, I want to know if this is will cause a problem in the long run.
I've been doing something similar recently, and it's working out pretty well. Couple of observations:
- You'll need to work harder than you otherwise would if you want the different views to have linkable url's, and maintain history so things'll work okay with the browser back/forward buttons. (although you might not care about that)
- You've got one big upfront page load when the user first visits the site - could be slower than splitting the pages out.
- There's no granularity to the site caching; if you change one character on one page in the site, the whole thing needs to be reloaded. In contrast to if you spilt the pages out and later change one of the pages, any HTTP caches will still be okay for the other pages.
- Switching templates via AJAX might give you slightly less UI feedback than standard page loads, EG if the connection is slow, clicking on a regular link would at least show me that the page is loading, wheras an AJAX call would be spinning away in the background. I'm not sure this'd apply in your case tho as it sounds like you'll have all the HTML pre loaded and just switch which bits are visible. In a similar vein pages which populate their content via AJAX might render less gracefully whilst they are loading.
- And obviously - If the user doesn't have javascript turned on, you're screwed. I'm not sure if anyone cares about this anymore, but I guess it might also impact SEO.