My app is composed of multiple mini games. Each of them is loaded in an iframe and have their own server.
The majority of them are written in clojurescript/reagent.
The problem is that loading the javascript is slow and very slow on mobile.
I'm trying to load only few games and then load the others on demand but that's also a problem because I need to be able to switch games quickly.
I just feel the root of the problem is I don't know how to share the commons lib. Ideally (I suppose) I would serve google closure and other common libs only once from the main app and the others iframe could use it or at least cache it.
iframes are on the same domain sub/domains.
Any idea on how to speed up the load time ?
(maybe the iframe is a bad idea and I would like to discuss alternatives)
As Colin said, my advice is to measure everything using something like chrome tools, react's chrome tools or wireshark to find out how long each operation is taking.
If it turns out not to be the network you could be reaching a worst case with react and/or reagent. Maybe your games are too complex for the differencing algorithm and too much is changing each frame or you aren't using key= properly. One copy may work fine but maybe it doesn't scale. The react chrome tools should help you figure out what is going on.
Surprisingly, iframes can come in handy but less so as a UI feature and more as a performance tool. We have a page that has to display a small window of uncompressed video from a web socket onto a canvas element at 16-24 frames/sec and doing this in the main page/thread sucked up so much cpu that other background processing on the page was delayed or blocked and we were forced to move it to its own iframe. Most browsers give each page at least one thread, including iframes. YMMV.
Good luck.
Alan
--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/wiCdwrjjAQ8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To share you code you can try using closure modules: http://swannodette.github.io/2015/02/23/hello-google-closure-modules/
You setup will be something like this: 1 common shared module and then each game is a separate module that depends on the common module. Then you'll get n+1 js files. In each iframe you need load common module and a game module. But common module should be cached so you browser ends up loading it only once for the first game and reusing it from cache for all other games. Browser still needs evaluate js file in each iframe, but maybe it don't take too long.
Nikita