128 points · by grabeh · 10y ago · 34 comments
Thanks for commenting, this is a cool experiment I worked on, just trying to eliminate the bootstrapping delay. Will be happy to answer any questions here, via issues in the demo repos (https://github.com/bahmutov/instant-vdom-todo), or in the library repo https://github.com/bahmutov/bottle-service
The demo itself runs from https://instant-todo.herokuapp.com/ (please use Chrome or Opera or enable ServiceWorker in the Firefox for now)
PS: Here is a little bonus, my current exploration where ServiceWorker might be useful - run your server (like ExpressJS) inside the ServiceWorker ;) https://github.com/bahmutov/express-service
Basically just re render the app after each change. Works pretty well and no need to setup pre rendering flux capacitor dual node virtual dom isomorphic gulp flow.
> The larger question I want to answer is this:
> Can we recreate the same "instant" page loading experience in our web application without the server-side rendering
If one were using a web server, virtualdom is easy to render on the backend. Also it would be simpler than having to patch sluggish UX with pjax.
There is also something interesting I've seen before in Java & Scala. It will run your code and render it automatically in the browser. If the other parts of the code is not finished it will later send it to be rendered to the web page. It happens in a single url path and it is not a single page application. Does anyone know what this is called?
Edit: I figured it out, by using playframework you do this by send a chunked response by streaming it. https://www.youtube.com/watch?v=l7IYY08Bb_4
So you can stream chunks in node as well: http://stackoverflow.com/questions/11906198/node-js-write-ht...
Strongloop: https://strongloop.com/strongblog/streaming-chunked-html-nod...
We've never had anybody complain about speed. If you can return responses in 100-300ms your good to go.
I do know it's limitations and that's keeping a lot of state in the client. In that case I'll usually fall back to rivets or vuejs. Yes I said fall back. People tend to go to a JS framework as the first solution. In my experience that's usually not a good idea. You'd be surprised how little you need a JS library, with a solution like Turbolinks
Exactly. We have always been able to do ajax loading even before Turbolinks. Client-side applications are a whole different matter, they have a level of interactiveness that is way beyond what's possible by sticking to server-side rendering. This is not a pissing contest, I just think your comment missed the point.
For everyone else, there is server side rendering.
It would be very interesting to explore just sending the newly created page back to the server and then using it for new page loads. The state could be updated after the load. Code is needed to update the state anyway in normal usage.
The behavior documented in the videos (refreshing the page) could make use of session storage as well as local storage, which might buy a bit more space. But unlike local storage, session storage is not shared across tabs/windows nor persisted over browser restarts. So session storage isn't really useful for the bigger problem.
IndexedDB is limited by same 50MB, 5MB on mobile, and is only partially supported by IE, Safari and iOS.