Live data from Hacker News

Intercooler.js – Simple AJAX Using HTML Attributes

intercoolerjs.org

11–20 of 53 posts

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#11

Great, another 60KB library (not including dependencies!) that can replaced with a few lines of plain Javascript without any dependencies.

It's 10KB gzipped (30KB non-gzipped) + jQuery. And that is pretty much everything you need.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#12

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.

Like another poster said. This would be useful if you’re using a server side rendering framework like ASP.NET MVC and you just needed a little bit of AJAX.

You would maintain most of your HTML, routing logic, etc. server side.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#13
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)

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#15
Sometime ago I had an idea that SPAs exist mostly because animated transitions between pages make managers happy, not to serve any actual user need. If that's true, maybe we could add support for animated transitions between server-side rendered pages, and make SPAs mostly go away.

Then I realized we could do that easily with a JS library! We could give some divs a "sticky-id" attribute, so they stay as part of the DOM tree when the page reloads, only their contents get replaced with the contents of divs from the new page having the same "sticky-id". That way there's no flash to white, and CSS transitions on sticky elements get a chance to fire. The whole thing could be handled by a generic onclick handler on each link. And the links would support opening in new tab as well, the JS would only fire when they are clicked in the same tab. I think that would be the most conservative way to have an SPA-like experience with a minimum of JS. Unfortunately I was too lazy to implement it :-/

EDIT: It's interesting that most replies to this comment seem to talk about whole page transitions, like fading out the whole page. But as I envisioned it, the key part of the idea is that we can get element-by-element transitions without writing custom JS, just by adding "sticky-id" attribute to some elements and letting their CSS transitions do the work.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#16

Sometime ago I had an idea that SPAs exist mostly because animated transitions between pages make managers happy, not to serve any actual user need. If that's true, maybe we could add support for animated transitions between server-side rendered pages, and make SPAs mostly go away. Then I realized we could do that easily with a JS library! We could give some divs a "sticky-id" attribute, so they stay as part of the D…

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

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#17
post #16

Sometime ago I had an idea that SPAs exist mostly because animated transitions between pages make managers happy, not to serve any actual user need. If that's true, maybe we could add support for animated transitions between server-side rendered pages, and make SPAs mostly go away. Then I realized we could do that easily with a JS library! We could give some divs a "sticky-id" attribute, so they stay as part of the D…

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

Neat! Though the point of my idea is having animated transitions between pages, by replacing contents of sticky elements and letting their CSS transitions work as usual. As far as I can tell, turbolinks doesn't do that.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#18

Sometime ago I had an idea that SPAs exist mostly because animated transitions between pages make managers happy, not to serve any actual user need. If that's true, maybe we could add support for animated transitions between server-side rendered pages, and make SPAs mostly go away. Then I realized we could do that easily with a JS library! We could give some divs a "sticky-id" attribute, so they stay as part of the D…

history.pushState() aka pjax

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#19

Sometime ago I had an idea that SPAs exist mostly because animated transitions between pages make managers happy, not to serve any actual user need. If that's true, maybe we could add support for animated transitions between server-side rendered pages, and make SPAs mostly go away. Then I realized we could do that easily with a JS library! We could give some divs a "sticky-id" attribute, so they stay as part of the D…

JQueryMobile does this (automatically applying to all anchor links): https://jquerymobile.com/

Various page transitions can be set using `defaultPageTransition`: https://demos.jquerymobile.com/1.4.5/transitions/

Click the "page" button to the right of a transition for a demo.

Re: Intercooler.js – Simple AJAX Using HTML Attributes

#20

Great, another 60KB library (not including dependencies!) that can replaced with a few lines of plain Javascript without any dependencies.

It's 10KB gzipped (30KB non-gzipped) + jQuery. And that is pretty much everything you need.

AND you can use Zepto (7KB) instead of JQuery.

I wouldn't call Intercooler heavy, au contraire.

Post reply on HN