Comment by emmanueloga_

3 months ago

In the meanwhile, I found that enabling page transitions is a progressive enhancement tweak that can go a long way in making HTML replacement unnecessary in a lot of cases.

1) Add this to your css:

    @view-transition { navigation: auto; }

2) Profit.

Well, not so fast haha. There are a few details that you should know [1].

* Firefox has not implemented this yet but it seems likey they are working on it.

* All your static assets need to be properly cached to make the best use of the browser cache.

Also, prefetching some links on hover, like those on a navbar, is helpful.

Add a css class "prefetch" to the links you want to prefetch, then use something like this:

    document.addEventListener("mouseover", ({target}) => {
      if (target.tagName !== "A" || !target.classList.contains("prefetch")) return;
      target.classList.remove("prefetch");

      const linkElement = document.createElement("link");
      linkElement.rel = "prefetch";
      linkElement.href = target.getAttribute("href");
      document.head.appendChild(linkElement);
    })

There's more work on prefetching/prerendering going on but it is a lil green (experimental) at the moment [2].

--

1: https://developer.mozilla.org/en-US/docs/Web/CSS/@view-trans...

2: https://developer.mozilla.org/en-US/docs/Web/API/Speculation...

In many cases, browsers will also automatically perform a "smooth" transition between pages if your caching settings are don well, as described above. It's called paint holding. [0]

One of the driving ideas behind Triptych is that, while HTML is insufficient in a couple key ways, it's a way better foundation for your website than JavaScript, and it gets better without any effort from you all the time. In the long run, that really matters. [1]

[0] https://developer.chrome.com/blog/paint-holding [1] https://unplannedobsolescence.com/blog/hard-page-load/