Never heard of Unpoly, but seems really cool. I will need to have at look at it more closely but from the brief look I'd say SPX is vastly different.
In SPX every single page visit response (the HTML string) is maintained in local state. Revisits to an already visited page will not fire another request, instead the cache copy is used, similar to Turbo but with more fine grained control. In situations where one needs to update, a mild form of hydration can be achieved. So by default, there is only ever a single request made and carried out (typically) by leveraging the pre-fetch capabilities.
If I get some time in the next couple of weeks I'll finish up on the docs and examples. I'm curious to see how it compares to similar projects in the nexus. The hype I've noticed with HTMLX is pretty interesting to me considering the approach has been around for years.
Interestingly enough and AFAIK the founder of github Chris Wanstrath was the first person to introduce the ingenious technique to the web with his project "pjax" - to see the evolution come back around is wild.
I recently read “Scar Tissue” by Anthony K who is the lead singer of Red Hot Chilli Peppers. I was given it as gift several years ago and just never got around to reading it. Well, let me just say that I did myself an injustice. It is a fascinating and captivating book. I didn’t expect it would interest me but it now exists in my top 10.
I do indeed. The project is called SPX (Single Page XHR) which is a play on the SPA (Single Page Application) naming convention. The latest build is available on the feature branch: https://github.com/panoply/spx/tree/feature - You can also consume it via NPM: pnpm add spx (or whichever package manager you choose) - If you are working with Stimulus, then SPX can be used instead of Turbo and is actually where you'd get the best results, as Stimulus does a wonderful job of controlling DOM state logic whereas SPX does a great job of dealing with navigation.
I developed it to scratch an itch I was having with alternatives (like Turbo) that despite being great are leveraging a class based design pattern (which I don't really like) and others which are similar were either doing too much or too little. Turbo (for example) fell short in the areas pertaining to prefetch capabilities and this is the one thing I really felt needed to be explored. The cool thing with SPX which I was able to achieve was the prefetching aspect and I was surprised no-one had ever really tried it or if they did the architecture around it seemed to be lacking or just conflicting to some degree.
A visitors intent is typically predictable (to an extent) and as such executing fetches over the wire and from here storing the response DOM string in a boring old object with UUID references is rather powerful. SPX does this really efficiently and fragment swaps are a really fast operation. Proximity prefetches are super cool but also equally as powerful are the intersection prefetches that can be used. If you are leveraging hover prefetches you can control the threshold (ie: prefetch triggers only after x time) and in situations where a prefetch is in transit the module is smart enough to reason with the queue and prioritise the most important request, abort any others allowing a visit to proceed un-interruped or blocking.
In addition to prefetching, the module provides various other helpful methods, event listeners and general utilities for interfacing with store. All functionality can be controlled via attribute annotation with extendability for doing things like hydrating a page with newer version that requires server side logic and from here executing targeted replacements of certain nodes that need changing.
Documentation is very much unfinished (I am still working on that aspect) the link in readme will send you to WIP docs but if you feel adventurous, hopefully it will be enough. The project is well typed, rather small (8kb gzip) and it is easy enough to navigate around in terms of exploring the source and how everything works.
Apologise for this novel. I suppose I get a little excited talking about the project.
I actually have a module that I built ti loads pages using such an approach (prefetch). In my take, I refined Pre-fetching to be triggered a few different ways. You can fetch on hover, proximity (ie: pointer is x distance from href), intersection or by programmatic preload (ie: informing the module to load certain pages). Similar to Turbo, every page is fetched over the wire and cached so a request in only ever fire once. It also supports targeted fragment replacements and a whole lot of other bells and whistles. The results are pretty incredible. I use it together with Stimulus and it's been an absolute joy for SaaS running projects.
I used to hang out with one of their engineers, he was a great guy and I tell you what, he took his job serious, lived and breathed the company and his work. Teenage Engineering is a small team and from what I know this tech was 5 years in the making. I think it is a great accomplishment from them.
So most of these projects are all maintained by members of the Mithril team or heavy contributors of Mithril, so you can trust they are created with care and have been thoroughly thought through.
You should definitely join the Gitter chat for Mithril. It's a very active channel and a little lesser known part of the internet where you will get a constant flow of engaged developers of all levels discussing Mithril and also where some of the core team discuss concepts, roadmaps, ideas and drop knowledge.
I enjoyed your article very much. I'm a huge fan and proponent of this framework. Since I come across Mithril I have used it exclusively on all internal projects at our agency and haven't looked back.
Adopting Mithril also opened me up to a whole list of lesser known but vigorously thought through projects like BSS, Patchinko and the beautiful Meiosis pattern which changed the way I went about developing resulting in far better productivity.
Two syllable naming conventions will always prove dominant.
- Goo-gle
- Faceb-book
- Twit-ter
- Snap-chat
- Git-hub
The list goes on and on. Duck-Duck-Go is just a poorly thought through name and the fact it's 3 syllable just makes it worse. At least with Instagram you can abbreviate it (ins-ta).
I'll use anything that the author of this article (Leo Horie) releases or is attached too. He is one of the greatest minds in JavaScript of this generation. After Angular, Vue and React I stumbled upon his framework Mithril.js and it was like I stumbled across the shroud of fucking turin, that framework is true poetry.
I choose Mithril.js regardless of the apps complexity nowadays. I've built apps in React and Vue and do agree that Vue is the logical choice over React but I don't see it as ground breaking or magical. I see Vue for what it is, A JavaScript framework that gained popularity by being included by default in the Laravel framework and now has good financial backing.
Mithril.js is a framework that is truly "magical" in my opinion. I mean its 8kb, includes routing and XHR Utilities out of the box. Faster render times than Angular, Vue and React. You can write HyperScript or JSX. The syntactic variants allow you to write your components as ES6 Classes or closures. Lifecycle methods, a render and mount option and the list goes on and on. People tend to dismiss Mithril because it's a lesser known framework but it has a vigorously thought through programmatic approach and you've got a direct line with the maintainers, you cannot match that.
Sure, each to their own but calling Vue "Magical" is an incorrect assessment.
As someone who has used 5-MeO-DMT several times, taken copious amount of "magic" mushrooms consisting of psilocybin, baeocystin and psilocin compounds I can only subscribe to the idea that our perception of "aliens" can only be viewed in altered states of consciousness while under the influence of psychedelics. Even in these states it's impossible to describe or comprehend what it is you are visualising and experiencing.
We as humans tend to think of ourselves as these all mighty and knowing species and the truth is if aliens did exist having us comprehend their state of existence would be like us trying to explain to an ant colony that they are ants and they live in a world where people still use the jQuery framework.
This was beautifully composed. I also use Mithril.js for most if not all my SPA builds. It’s an 8kb solid little framework and I can cook it into virtually any web application because of this.
Vue and React are great but in my experience they’re virtually an overkill for most projects. I recently come across a Shopify cart integration using Vue and was sorta dumbfounded that an engineer decided to include a 50kb framework to handle a couple of Ajax requests. I ask myself why? The answer is hype. Hype can be the demise sometimes.
Mark Zuckerberg cannot handle any form of criticism and it's just utterly weak. He constantly evaded questions and failed to give worthy answers. It was quite the spectacle.
All Mark Zuckerberg really needs is a swift punch in jaw. Nonetheless, I've boycotted Facebook and the masses will follow in due time.
In SPX every single page visit response (the HTML string) is maintained in local state. Revisits to an already visited page will not fire another request, instead the cache copy is used, similar to Turbo but with more fine grained control. In situations where one needs to update, a mild form of hydration can be achieved. So by default, there is only ever a single request made and carried out (typically) by leveraging the pre-fetch capabilities.
If I get some time in the next couple of weeks I'll finish up on the docs and examples. I'm curious to see how it compares to similar projects in the nexus. The hype I've noticed with HTMLX is pretty interesting to me considering the approach has been around for years.
Interestingly enough and AFAIK the founder of github Chris Wanstrath was the first person to introduce the ingenious technique to the web with his project "pjax" - to see the evolution come back around is wild.