Replies: 12 comments 5 replies
-
Sounds like something that might cause multiple request for the same namespace as one namespace might load another one. This is why they are loaded in order (same as in Clojure on the JVM for example). |
Beta Was this translation helpful? Give feedback.
-
Btw feel free to poke around in sci/async.cljs if you wish. |
Beta Was this translation helpful? Give feedback.
-
sci loads each namespace that has not been loaded ONCE. This works fine. Say I want to render a page, that should |
Beta Was this translation helpful? Give feedback.
-
Currently, yes, exactly BECAUSE requires are serialized. |
Beta Was this translation helpful? Give feedback.
-
Normally responses from servers can be cached though so after caching it should load very quickly. |
Beta Was this translation helpful? Give feedback.
-
The server is replying FAST. This is not the issue. The issue is that sci sends one request, then waits for the answer. The the next request, then wait for the second request, etc. What kills me is the ROUNDTRIP time to the server. If sci would send |
Beta Was this translation helpful? Give feedback.
-
Perhaps I should elaborate a little bit how I use sci. So I use shadow-cljs for clojurescript modules that get compiled into js bundle (or separate js modules if they are big). I expose to the sci context all namespaces of compiled clojurescript with the same |
Beta Was this translation helpful? Give feedback.
-
sci async-load-fn: |
Beta Was this translation helpful? Give feedback.
-
This is not the point. If responses of assets (.js files) are cached, a request shouldn't even take a 1 millisecond. It seems you should fix that problem first. As I said, feel free to explore parallel loading, the code is in sci/async.cljs but I don't think it's actually a great idea and I have the feeling that it could create issues. What could for example happen:
For namespace |
Beta Was this translation helpful? Give feedback.
-
The server is always fast. When I run the app on localhost (or on the same lan), I have page load time of milliseconds. This is because I read your example. You have a good point! The problem is that the async-load-fn can use scia/eval-string, and that this can trigger further ns requires. You have the loading and the modifying of the context all together. I guess somewhere you calculate which ns to require. Perhaps this function can be used? Perhaps there can be an event that I do not want to create troubles :-) I am raising this point, because at some point every web-app that uses sci with a lot Thanks a lot for this wonderful project! (And all the others you do!) |
Beta Was this translation helpful? Give feedback.
-
The browser cache idea is a great one. So I just really need to request all sci cljs files on startup once, and then most likely |
Beta Was this translation helpful? Give feedback.
-
Great ideas! Thank you! I am using ths feature of shadow-cljs. For sci in developer-mode I am currently pushing new source-code |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I am extensively using the async-load-fn in the browser. It works pretty much perfect! When the webserver
that provides sends either modules or sci source code to the browser is in a local network, this process
is fast and works perfectly. However, when the server is far away, then there is a significant wait time.
This wait time is basically the roundtrip-time to the server multiplied by the number of namespaces that
are async loaded. This is because sci loads the libspecs one by one.
When there are say 20 namespaces that are required that need to be loaded via the async-load-fn then
when the server is far away, there are 20* 200ms load-time = 4 seconds.
Describe the solution you'd like
Sci sends out all the async-load-fn requests at the same time, and then just starts compilation once all
promises have been fulfilled.
Describe alternatives you've considered
My app uses multiple modules; this modules are finetuned, so only large modules (>100kB) get moved into their
own modules; smaller modules I moved to the main bundle. Where the roundtrip-time accumulation time is high, is
when the web app uses a lot of sci namespaces that are all very small, and the only reason to have multiple
namespaces is for a clearer code organization. I am considering bundling multiple sci namespaces to bundles of
namespaces, so that the async-load-fn does not trigger a fetch request that gets sent to the server that often.
Beta Was this translation helpful? Give feedback.
All reactions