Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy loading and resumability ala qwik #12

Open
tzual opened this issue Oct 15, 2022 · 11 comments
Open

lazy loading and resumability ala qwik #12

tzual opened this issue Oct 15, 2022 · 11 comments
Labels
enhancement New feature or request future

Comments

@tzual
Copy link

tzual commented Oct 15, 2022

consider adopting ideas from qwik framework.

leverage seralization on the client to enable:

  • lazy loading components - makes the app a lot faster to start
  • resumability between sessions - better user experience

i believe qwik is bringing some inovative ideas into the web app world and since this project is still in early development you can still possibly incorporate them.

@gbj
Copy link
Collaborator

gbj commented Oct 15, 2022

Oh, totally! In fact one of the reasons the reactive system in this library uses index-based arena allocation is that it means the whole reactive system can be serialized and deserialized.

I've experimented in the past with Qwik-style resumability in Rust. The main blocker right now is the Wasm bundle splitting story, which is not great. There's been some progress with the wasm-split tool from binaryen recently, and talk of integrating that with wasm-bindgen.

So, Leptos isn't resumable at the moment but has been designed so far for future resumability.

@gbj gbj added enhancement New feature or request future labels Oct 17, 2022
@benwis
Copy link
Contributor

benwis commented Nov 14, 2022

Very cool! I too have been eyeing wasm split with the idea of Qwik-style resumability. Hoping we can get that soon

@matthewharwood
Copy link

Is how qwik serializes events to HTML on the server side to client. They call this resumability
https://github.com/google/jsaction

@atdiar
Copy link

atdiar commented Jan 29, 2023

Just wondering how feasible it is really...
Javascript can serialize most functions (not all but most) and deserialize them using eval.

How does one do the same thing for rust functions?

Seems to me that this is only a possibly valid approach for javascript and then again I jave doubt about the arguments that this is much better... The resumability approach, while interesting, seems to be at best an early optimization of app startup time.

There are probably other tradeoffs. Just wondering there as I'm trying to see below the marketing.

@gbj
Copy link
Collaborator

gbj commented Jan 29, 2023

Just wondering how feasible it is really...
Javascript can serialize most functions (not all but most) and deserialize them using eval.

How does one do the same thing for rust functions?

You don't need to serialize the functions, per se. You just need to know which signals are updated from which callback functions (this is by far the hardest part), and be able to code split such that you can load the correct function from Wasm as needed (this is also hard.)

Qwik has put a ton of work into both of these things in a language they're much easier in.

Seems to me that this is only a possibly valid approach for javascript and then again I jave doubt about the arguments that this is much better... The resumability approach, while interesting, seems to be at best an early optimization of app startup time.

There are probably other tradeoffs. Just wondering there as I'm trying to see below the marketing.

You're 100% correct here. Qwik's team pushes resumability as the answer to every problem and the best thing ever. In reality, we can probably get a lot of the benefit with much-lower-hanging fruit like partial hydration/islands, and hybrid routing like Solid is working on right now.

@atdiar
Copy link

atdiar commented Jan 29, 2023

Well, part of why Qwik is able to not ship any javascript at startup is that they put the state in the Server Rendered HTML(including reactive functions I understand).

But then the functions have to be serialized too.
If someone has to ship wasm however, they basically have to send some file on first request which is claimed to be slowing everything. And load it at app startup.

To be fair, I don't buy that as I think that most of the potential slowness is caused by third party scripts and not necessarily application code.

But that's still one of the purported benefits of qwik that seems difficult to reproduce oustide of pure javascript.

If the wasm has to be sent AND loaded separately very first thing anyway, I am a bit dubious about the true utility of implementing resumability in this case.

If there is a solution for that, then why not of course.

@saolof
Copy link

saolof commented Feb 28, 2023

Resumability may have other advantages beyond just bundling/lazy loading, such as saving state in local storage.

Even if you don't load the code as granularly as qwik, resumability still makes hydration a lot easier.

@blueray453
Copy link

Just curious, Qwik Optimizer is written in Rust. Is leptos reusing that?

@gbj
Copy link
Collaborator

gbj commented Apr 1, 2023

Just curious, Qwik Optimizer is written in Rust. Is leptos reusing that?

I don't think this would be plausible. Qwik's optimizer may be written in Rust, but it's a tool for doing static analysis of JavaScript files to do code extraction, etc. Some of the same principles may well apply to trying to build resumability into a Rust framework but the optimizer itself couldn't be reused in any meaningful sense, I don't think.

@jbms
Copy link

jbms commented Apr 29, 2024

I've built a prototype implementation of code splitting with lazy async loading for rust wasm32-unknown-unknown. See rustwasm/wasm-bindgen#3939

@gbj
Copy link
Collaborator

gbj commented Apr 29, 2024

@jbms This is extremely good news. I've only skimmed your post so far but explicit module splitting is exactly what we need, not so much for resumability as for route-level code splitting, which would be fantastic. I will look at this more deeply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request future
Projects
None yet
Development

No branches or pull requests

8 participants