Structured Page Fragments by YouTube
youtube.github.io
youtube.github.io
0: https://www.facebook.com/notes/facebook-engineering/bigpipe-...
I realize that YouTube is a crazy hard problem to tackle, and that is probably why stuff like this is necessary.
In dynamic navigation, only fragments are sent, using JSON as transport.
Why not HTML as a transport?More complex state transitions such as form submissions appear to be provided for in the second argument of the spf.navigate method, which can take an object including a POST method specification and the corresponding data. It looks like that's about all the library provides in terms of request flexibility; per the code, setting custom request headers on navigation requests is definitely unavailable, but it doesn't do anything to override the default behavior by which XHR passes on e.g. Authorization headers already set by client code, so (in conjunction with e.g. OAuth) you'd be able to identify and authenticate the user making the request. I guess the idea is that, for the purpose the library's meant to answer, what it provides in the URI is just about all the information the server should need on what content to include in the response.
<div id="bar"></div>
<% link_to "Load #{@widget}", @widget, remote: true, id: 'foo' %>
$("#foo").on("ajax:success", function (e, data, status, xhr) {
$("#bar").html(xhr.responseText);
});
I thought rendering partials and dynamically replacing them has been a standard feature of most frameworks. Rails even renders a working link so the page works without the javascript.