I did some tests, deployed some new versions and can conclude following:
preloading was not the root cause of the issue. in addition the workaround I had for the local network is not necessary for the ic prod
indeed reducing drastically the amount of chunks solve the issue. app can now boot in chrome within a couple of seconds.
I did not bundle everything in a single file, even though it would be possible, because for an app like mine with such an amount of features it would mean shipping a 5mb loading blocking JS, what makes absolutely no sense.
Therefore, for a quick test, I removed (
npm rm ....) the design system (Ionic) and all my custom Web Components (around 30 libs) from the bundle and modified the app to fetch these from CDN (unpkg and jsdelivr) at runtime.
This indeed solve the issue but I am not fan of it, notably because doing so I loose all the advantages of the type safety provided by these libs and have to use external CDN instead of the assets hosting.
I will probably try to reimport the lib and then after build split the deployment of the JS files. I’ll try to deploy the main.js to the IC and all other bundles to a non blockchain static CDN, let’s see.
Being said, I don’t know if it is a proxy issue, as you said above, or a design issue but, it is really surprising to me that the IC does not handle, in terms of cost and performance, outcome of modern bundler which outputs multiple chunks such as Rollup.
I would be curious to know if it’s a issue, a feature, on the agenda or not on the agenda.