I mean if you just make the same endpoints on the server that you would have made back in he HTML serving days, but instead serve JSON, and then call that an 'api', then sure, yes, but then it's a distinction without a difference, you are just moving the rendering of the data into html from the server to the client, this only a small a api, not an API as in 'the thing you use for generic 3rd party programmatic access to your features'.
Also, rendering html on the client is silly and has no benefit, no matter how hip it is. It's not faster, it's not more efficient, it's much harder to test, it forces you to use a terrible language (javascript) instead of your-choice-of-any-language (which can still be javascript), it makes capturing errors harder, it dramatically increases the amount of code that has to be cross browser compatible and also has to support older browsers, and ditto all the bug stuff for performance. It's just a completely stupid idea that people are doing for no clear reason at all, generally because they have little experience and are just cargo culting whatever the cool kids with blogs are talking about.
First of all gzip will reduce this considerably. Both will end up much smaller, but also the % difference will be reduced, since the html version is likely to contain much less entropy per bit.
Secondly, in my version of how to do it, you can still use AJAX. It's fine to load blog posts via AJAX, and in that case you aren't reloading the boilerplate of the page? I am saying to return rendered html in the response rather than returning json and rendering it into html in the browser. The specific data returned can be the same either way, and the overhead of html over json in the case of a set of blog posts should be tiny, and depending on how much markup the posts themselves contain, the html version is quite possibly going to be smaller.
Universal JS apps can help here. Render the JS app page server side using a thin Node server, hydrate the fully formed DOM on the browser and run it client side from there. Truly, the best of both worlds.
Twitter did have to backtrack from the #newtwitter pure client-side model. Serving a 140-character string shouldn't require a 1+ MB payload. So maybe they server-generate their pages this way too now.
http://rackt.github.io/redux/docs/recipes/ServerRendering.ht...
https://github.com/GordyD/3ree/blob/master/server/universalA...
We built Userify[1] (ssh key management for EC2 & elsewhere) entirely using this model (REST API) because it gives us a clean way to inspect incoming data and respond with pure JSON.
Since it's just JSON over HTTPS, clients are all easily implementable in any language (i.e., Javascript and HTML5 for the web app, beta client SDK's currently in Python and JS, more on their way), or just a curl shell script. (The agent[2] is just a single Python script with no dependencies.)
And, now, with great tools like Phonegap/Adobe Build/etc, you can convert your responsive mobile web app into an Android or iPhone app in seconds (performance is no longer an issue, either).
Best of all, you maintain a clean separation of concerns and isolation between your API resources and the front end.
Compared to the server-driven ways from the last century, this is so much better; we can provide a full desktop app experience, make it feel more like a web page, or anywhere in between.
AJAX changed everything. This is simply better.
It's not static front-end, but SPA - Single Page Application. It's the part of the larger Serverless / Backend-less computing trend.
We already have:
- static websites (i.e. served from Amazon S3 or Google Cloud Storage)
- static blogs and CMSes
- frameworks for SPAs (Ember.js, Angular, etc.)
- Firebase and the likes
- Amazon Lambda and the likes
And yes - Serverless is the future.
> Write the back-end initially in RoR or Flask, move it to Elixir or Scala when your servers start crashing.
why not to write it in Phoenix/Elixir from the start? I don't think it's any more harder than RoR.
And there are many blank pages I get to see, because of this kind of Architecture and CDN's. Nowadays even blogs with mostly static content don't work. That's realy annoying.
If you depend on search engines, remember you get penalties for this kind of sites. You need to have some kind of prerendering to satisfy you ChiefSearchEngineOptimizer.
How do you support Bookmarking in a Single Page Application? I think this is an essential feature and not trivial to implement correct.
I tried Angular. It works. It looks nice and smooth, but I don't think it is a good solution. JS is nice as an enhancement, but I don't like it as a dependency to use the web.
===Addit Not so long ago we have had similar approaches to JS-SPA. They were called Java Applets and Flash. These Technologies are dead. Everything you do today with JS was 10 years ago possible with these technologies. The only constant in the web that's gonna stay is HTML.
JS is overused. There are so many things you're better off without JS, like Blogs, Hackernews or simply valueable content. There might be usecases for SPA, but a high percentage are better off without these cool and fency stuff.
Eliminating Serverside Rendering for scalability reasons as a first step is often followed by implementing prerendered content in script-Tags or via react on node. The only thing that gets scaled is complexity.
As for bookmarking - any dynamic single page content site and many applications will support linking directly to a certain content or section of the app via various techniques.
JavaScript is not a nice enhancement. It IS the web.
If you don't degrade well under those circumstances you're at a competitive disadvantage to sites which do something like quickly return a core HTML page which can display immediately while the full app loads.
> How do you support Bookmarking in a Single Page Application? I think this is an essential feature and not trivial to implement correct.
I'm not sure I've ever seen this be a problem. You make sure the app is served from any route that exists within the app, and the app's router loads the correct content based on the url when it boots up.
I'm surprised even 10% of sites show anything these days. I get a lot of broken sites just by disabling tracking and ads.
I can imagine disabling js would be much like disabling half of the html tags.
People always mention disabled JS and SEO as pitfalls but I think performance and practicality are the obvious reasons not to do this that get overlooked. SPA architecture is something I use alongside server rendered pages. When you have one page or a series of pages in a particular user flow that would benefit from no page reloads and are heavy on interactivity then it makes sense but otherwise I can't see the value. I think developers will realize this and take a more balanced approached with a practical mix of pages rendered server side and pages that use XHR and JavaScript to enhance the experience.
How, exactly, do you know this?
Sure, it's probably a reasonable guess. I just wonder how many of the people making this claim are simply assuming it to be true or relying on some sort of analytics service. About the only way you could tell is by counting the server logs, which I'm often told are hard/annoying/unavailable by analytics advocates.
So far, the metrics prove it's possible and we're quite happy with it. Interaction after slightly larger initial loading time (kept low via SPDY / HTTP/2 CDN) is much more snappy than the classic approach. Also, Prod/Dev parity is higher now that we're using exactly the same JS "build" in stage and prod.
Rankings are great, just prerendering took some more engineering to set up reliably than we thought. I can recommend the guys at SEO4AJAX, they've got great engineering and customer support compared to the market leader.
I wish more people would do that :)
I'm not too familiar with the new front-end frameworks, do any of them support this seamlessly? If not, I'm surprised, it seems like a fairly straightforward thing to architect.
What dismays me more about the rise of the static front-end single-page-app, is it really means the death of the idea of the architecture of the web. It's going in the opposite direction from the 'semantic web' dream, as well as REST.
But crawlers and "single-page" Javascript apps are another potential problem, sure, although not the one the OP discussed.
But wanting actual HTML in the original non-JS delivery for crawlers is I guess why people have followed the 'universal JS' approach instead of what we're talking about here.
Other comments in this post suggest that Google, at least, does fine with Javascript-generated pages these days. I have no idea myself.
Nothing about this 'architecture' is new in any way.
I was under the impression that identical URLs were rejected as dupes?
We do reject identical URLs for a few hours to avoid stampedes of popular posts.
Is it OK to regularly submit twice in two days? I see that pattern with OP.
Reposts aren't necessarily a problem if the story hasn't had attention yet. On HN we want to optimize for curiosity, which means getting the best candidate stories in front of the community. Since /newest by itself does a poor job of that, we've been experimenting with other approaches.