Live data from Hacker News

Intercooler.js – Simple AJAX Using HTML Attributes

intercoolerjs.org

41–50 of 53 posts

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#41

i work on intercooler, you can AMA as usual, a lot of negative comments from HN on the approach (which is admittedly against the grain) but I've used it for a relatively large and successful web app (rails back end) and it has worked out well compared to the SPA architectures I've had to deal with i think the philosophical roots in REST/HATEOAS are worth considering, if you are open minded: http://intercoolerjs.org/2…

Have you tried something like prmd [0]? And if so, what are your thoughts on it?

I used it at my previous job, but didn't find it gave me that many benefits, although there wasn't anything particularly wrong with it either. It just seems like a challenging problem to properly solve with any organization.

I was initially really interested in GraphQL and Relay, but when I tried em out I found em lacking for our small engineering team. I feel kinda similar with all these other alternative tools. I think if you have any API stability problems, you need to tackle it at an organizational level. The API team needs to communicate openly with the web frontend and mobile app team (which might include a cross-section of highly-mixed-specialty people) to make sure all changes are fully backwards compatible. I don't think the tools do a great job at helping you tackle complex issues.

[0] https://github.com/interagent/prmd

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#42

i work on intercooler, you can AMA as usual, a lot of negative comments from HN on the approach (which is admittedly against the grain) but I've used it for a relatively large and successful web app (rails back end) and it has worked out well compared to the SPA architectures I've had to deal with i think the philosophical roots in REST/HATEOAS are worth considering, if you are open minded: http://intercoolerjs.org/2…

Have you tried something like prmd [0]? And if so, what are your thoughts on it? I used it at my previous job, but didn't find it gave me that many benefits, although there wasn't anything particularly wrong with it either. It just seems like a challenging problem to properly solve with any organization. I was initially really interested in GraphQL and Relay, but when I tried em out I found em lacking for our small e…

I have used swagger a bit for JSON API development, but didn't find it added much over just keeping it simple and reacting to client needs.

I typically split my externally facing JSON API out from the main application (which uses HTML/intercooler) because the use cases are typically so different: the JSON API needs to be general and abstract whereas the web application UI has a lot of fiddly little specific data needs that are better implemented on the back end, where you have full access to the domain model and a proper query language.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#43

I'm missing something. What's the problem they are solving? It looks like they are offering a more limited way to make AJAX calls. Why? To add -- it depends on jQuery? Yeah, I'm gonna have to pass. What this thing does is so small that I can't fathom why they would need to import all of jQuery just to provide a new way to do AJAX requests. I'll just keep using React, it probably already solves whatever problem is try…

if it helps you can think of intercooler as HTML++, addressing the shortcomings of HTML (only supporting GET/POST, only allowing clicks/submissions to generate requests, only targeting full page replacements, etc.) rather than trying to be something like React.

It isn't right for everything, but it works well for me w/ a rails back end and there are some good theoretical reasons for using HTML if you like REST/HATEOAS. I linked a few articles up thread you can read if you are interested.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#44
post #2

Is it just me or "Live Demo" actually doesn't send any AJAX requests?

yeah, I mock the ajax requests out so I don't have to host a server-side app

you can click on the code tabs and see what's going on, and it should be easy enough to map to whatever backend technology you are using

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#45
post #33

http://barbajs.org is superior in every way.

lol intercooler does a ton more than barbajs does with almost no javascript, they aren't even comparable

as w/ pjax or turbolinks, barbajs is a fine library, but it isn't trying to create HTML++ and there isn't much REST-ful theory behind it

i'm sure it's good for a lot of stuff though

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#46
post #16

Earlier quoted context omitted.

https://github.com/turbolinks/turbolinks is pretty close?

Turbolinks looks neat, but our Ruby app selectively includes CSS and Javascript snippets outside the tag depending on what page is loaded (using :content_for declarations in our templates). I am guessing that Turbolinks will not work for us in this case, as the relevant external files will not be called on page load?

turbolinks swaps out the and merges the tags of the incoming page with the existing tag.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#47
post #16

Earlier quoted context omitted.

https://github.com/turbolinks/turbolinks is pretty close?

Turbolinks is cool but it seems more tied to only a rails backend. Anyone know how to use it with Java?

It's independent of Rails. It simply hooks the all calls to tags and replaces them with ajax get requests to the url.

It works really nice with Rails because of how easy Rails makes it return a piece of javascript to the page (this is called SJR) so there is some magic included for making form submissions work which is part of the Rails turbolinks gem. The javascript that the server returns to the page essentially calls Turbolinks.visit("/url-form-submission-would-redirect-to-after-completion") so that the expected navigation takes place. It's quite clever. I think you would have to replicate that in the Java world to get the full experience. This SO answer alludes to how you might replicate SJR https://stackoverflow.com/questions/26750738/java-spring-ret...

So I think out of the box you can expect clicking links to work (and that alone provides a great speedup), but ajax form submissions will require some work. If you look at some articles on how form submissions with turbolinks make use of SJR you could likely figure it out and implement it. It's overall not a very complicated mechanism.

I suppose Rails .erb templating engine also has some helpers which the form submission side of turbolinks relies on. Namely it includes a data attribute data-remote and that's the thing turbolinks hooks into to prevent the default behavior of the form submission and and instead fire the ajax request. In theory so long as your forms include that it will work if you have the SJR stuff in place on your back-end.

You could definitely roll full support for it.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#48

This is fine if you build a website or a small app. But I wouldn’t recommend this approach for a more serious/big app. You will end up with unmaintainable soup.

My experience building a large flask app with jinja2 templating (large in that the app is ultimately a mix of ERP/manufacturing management/customer+supplier portal). The intercooler approach combined with flask blueprints and template folders is extremely maintainable. It is easy to comprehend all aspects of what is going on at any time. Can get a decent developer up to speed to be productive with it, within days. The vast majority of businesses would never need a heavier framework than this.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#49

I tried this library before but Vue does pretty much the same thing and is way more powerful. Additionally, starting out with Vue makes transitioning to a SPA much easier when needed. I also encountered some bugs when mixing the 2 during a transition phase that broke my requests. If I had to start over again I would only use Vue starting with the drop in JS library (no webpack/preprocessing)

It may be worth mentioning that Vue is an entire framework with a crapload of features and caveats and whatnot and thus not exactly an equivalent of an especially flexible PJAX library which is the best definition I can come up with when defining Intercooler

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#50
post #49

I tried this library before but Vue does pretty much the same thing and is way more powerful. Additionally, starting out with Vue makes transitioning to a SPA much easier when needed. I also encountered some bugs when mixing the 2 during a transition phase that broke my requests. If I had to start over again I would only use Vue starting with the drop in JS library (no webpack/preprocessing)

It may be worth mentioning that Vue is an entire framework with a crapload of features and caveats and whatnot and thus not exactly an equivalent of an especially flexible PJAX library which is the best definition I can come up with when defining Intercooler

Vue is not a framework, at least not in it's simplest form - drop in UI library.

I agree that Vue does much more than Intercooler and in theory, it could be seen as an overkill. But in reality, a developer will probably use it in conjunction with jQuery and then he might be better off replacing these two with Vue.js

Post reply on HN