by pilif · 15y ago · 0 comments
We've seen how well such sites are received when HN was dominated by blogs ranting about the new Gawker design.
So to fix this, you'd have to do three applications:
1) the API that you use in the JS GUI
2) The JS GUI
3) The dynamically generated HTML for JS-less browsers
Or you change the JS GUI so it requests page fragments and work with history.pushState (PJAX) allowing you to skip the API again, though, of course, then you don't have an API.
I've reasoned about this last april: http://pilif.github.com/2011/04/ajax-architecture-frameworks...
The server would offload as many procedures to the client as possible (that is none if js is disabled, some if you don't want to expose your guts).
The server html renderers would be the exact same code in the client, the api would be a simple thin wrapper around your "protected" procedures.
You could event support ecmascript5 features on IE6, executing the js in the server.
But, of course, if you go the JS only route (which I have done for my tempalias.com fun project last year), then you also have to keep in mind that you will be duplicating model code and dealing with two separate ORM layers:
One on the server for the API itself and one on the client which gets used by the GUI controllers. Backbone can be of help there, but if you want to, say, do some validation logic already on the client without the roundtrip, then you begin duplicating logic on both server and client.
So how ever you put it, going JS only is probably more work in the end, but it's also less work than going the traditional way and then bolting on a fully-fledged API because the lack of dogfooding it will cause you trouble once you get real users for it.
Overall it's a really difficult decision to make and it's also quite final as changing the direction, again, means a lot of work.
I find the 'javascript to enhance' guideline helpful to. Then sites are more likely to be functional (but not pretty) in older browsers. A good example is javascript to make menus slide, but which use CSS to make them come up.