5 ms·
> You have the API inflexibility and UX restrictions of a pure-HTML approach I don't see this. Can you elaborate? > combined with the overhead In what sense?
by andybak 10y ago
> You have the API inflexibility and UX restrictions of a pure-HTML approach
I don't see this. Can you elaborate?
> combined with the overhead
In what sense? Bandwidth? Rendering? Conceptual?
> and need for graceful degradation of a full-ajax approach.
I've found intercooler suits a 'graceful degradation' approach rather well. It is a small evolution of on from pjax/turbolinks - which itself epitomises progressive enhancement/graceful degradation.
- xg15 10y ago> andybak 7 hours ago | parent | on: Intercooler.js – Making AJAX as easy as anchor tag... > You have the API inflexibility and UX restrictions of a pure-HTML approach I don't see this. Can you elaborate? No client-side rendering. More precisely, the core idea of intercooler is that every UI update polls the server for new markup. So for each non-trivial UI change, you have to take into account the latency of a network request, even if you already sent the data to the client before in another request. That makes the "feels like a desktop app" experience impossible that originally was one of the major selling points of ajax. The "markup snippet" means that if you want to change your UI, congratulations, you have to change your template and your API - whereas with client-side rendering you wouldn't have to touch the API at all in many cases. > In what sense? Bandwidth? Rendering? Conceptual? Conceptual. You have the same complexity costs as a full ajax page compared to a plain-html page (data gathering spread over multiple requests, need to define an API boundary, need to care about clients without JS support, need to track client-side state, etc.) - but it seems to me you get a lot less benefits for that cost. > It is a small evolution of on from pjax/turbolinks - which itself epitomises progressive enhancement/graceful degradation. I admit I'm not familiar with that. But how would it deal with clients without JS support?
- ryanbrunner 10y ago> That makes the "feels like a desktop app" experience impossible that originally was one of the major selling points of ajax. The vast majority of single-page applications I see on the internet nowadays still function in a way that would be perfectly serviceable if they were implemented without AJAX. Absolutely there's cases where the request-response cycle doesn't map well to what actually happens in the app, but I don't think anyone is claiming that Intercooler, or serving HTML from an AJAX request, is the final answer in building web apps. Everyone seems to forget about using the right tool for the job when the right tool is unsexy.
- xg15 10y agoWhat I don't understand is what benefit serving HTML from Ajax would bring you in the short time if you plan to switch to JSON anyway. Wouldn't that be one unnecessary backend rewrite?
- ryanbrunner 10y agoWell, a couple of things there: 1. You may not plan to switch to JSON anyway. Serving HTML, whether through a full request or AJAX can be perfectly fine. The site we're on now has no real Javascript of note, for instance. 2. You might introduce a JSON API for customers, but that doesn't mean that it needs to or even should be the same API you use internally. 3. Even assuming that you know that you'll ultimately move to a JSON API, it can be advantageous to take a quicker approach while you're still figuring out the solution. When you come back to the API, you'll have a better idea of precisely how it should be used.
- xg15 10y agoWell, those are fair points, I agree.
- rimantas 10y ago> No client-side rendering That's a good thing. Devs should really spend some time thinking why they do something in particular way instead of just parroting others.
- xg15 10y agoIndeed. But as I wrote I think there are some good reasons why client-side rendering brings benefits in most of the cases - assuming you have already decided to use ajax.
- scwoodal 10y ago> I admit I'm not familiar with that. But how would it deal with clients without JS support? One could include two attributes: <a href="/foobar" ic-get-from="/foobar">foobar</a> There's likely some edge cases that would fail doing it this way, like when including other inputs outside of the form tags when submitting forms.
- xg15 10y agoAs I understood it, the whole idea of intercooler is to fetch HTML snippets via ajax and embed them into the page client-side. Your fallback would require server-side logic to decide whether to return the snippet or render the whole page client-side. That's just as complex as fallback for a traditional SPA.
- scwoodal 10y agoThere are a few different strategies when using intercooler. If clients not having java script available is a big concern the server can always return fully rendered pages and have intercooler pick out the elements from the response that need to be updated on the page. This gives clients that do have java script the feel of an SPA and clients that do not have java script see the traditional full page refresh without any additional server side logic deciding to return snippets or not.