Hacker News new | comments | show | ask | jobs | submit login

I've implemented this before. The site was standard MVC, built in CodeIgniter. I then built a middleware layer that would either decorate the content with a layout template to generate the HTML version or create a JSON structure with linked elements (CSS and JS files) and page title.

The JavaScript would parses the incoming JSON and attach listeners to all the elements. It had to do a few tricky things like tracking JS and CSS files and provide alternatives to dom:loaded so scripts could be rerun on dynamically loading content. Really Simple History was then used to track the state.

I built and tested the functionality as a plain HTML site first then builf the dynamic loader afterward, which was relatively easy to implement. Some of the trickiest parts were gettingand the DOM to update in a timely fashion and to get the interface to "feel" right (when do you clear the old page, when do you scroll user back to top of page, etc.).

Like emilis said, there are still a few small cases where the implemetation breaks down, mainly when sending or publishing links. I ended up enforcing clean links: if you hit a HTML page when you had JavaScript enabled it would take you to the homepage and reload your desired page from there. This was mainly because not doing so would make the copy-paste problems worst. E.g. If you expecting to see "bar" but had no JavaScript then example.com/foo#bar (showing foo rather than bar) would be more confusing seeing the homepage at example.com/#bar. The redirect logic was the first thing encountered on the page so was pretty quick. E.g. http://www.google.co.uk/search?q=http%3A%2F%2Fwww.thebeatles...

I wouldn't recommend implementing this unless you absolutely had to. For me the requirement for a streaming music player was a "must-have" feature. Even the quickest page load would still lead to skipping music.

"I then built a middleware layer that would either decorate the content with a layout template..."

Methinks you might have a somewhat non-standard definition of the term middleware. Please have your buzzword generator re-calibrated ;)

Too much time spent around Django :P

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact