Hello! I'm looking for ways to shrink my app size ...
# compose-web
j
Hello! I'm looking for ways to shrink my app size since it takes approximately 10 seconds to load the .wasm file, thus, the user has to wait 10 seconds just to be shown the initial screen. Is there some way to configure this? Currently, I have the following configuration
Copy code
const TerserPlugin = require("terser-webpack-plugin");

config.optimization = config.optimization || {};
config.optimization.minimize = true;
config.optimization.minimizer = [
    new TerserPlugin({
        terserOptions: {
            mangle: true,    // Note: By default, mangle is set to true.
            compress: true, // Disable the transformations that reduce the code size.
            output: {
                beautify: false,
            },
        },
    }),
];
inside
config.js
under webpack.config.d which produces 6MB composeApp.wasm file.
3
Perhaps is it possible to preload the composeApp.wasm in index.html and then initialize the app myself in JS?
b
Please make sure you are using a production build and your server supports compression (the best result could be achieved with brotli compression). Teaser: In upcoming 2.1.0-Beta2+ we expect 20-30% size improvement in prod builds Proper setup of preload may help in the first visit, but following visit well handled by browser cache.
💪 7
🦜 5
very nice 4
💪🏾 2
Terser optimizes only JS files, and for wasm we don’t generate much js code. Anyway, Terser should be used by default in prod builds.
1
j
Do you or anyone else have a working sample of the preload implementation? There are two Wasm files, one of which has a random "magic number," so I suppose it can't be preloaded. But when I do preload the composeApp.wasm, the console shouts at me, that the file was not used within seconds, do I have to manually append it to the WebAssembly?
b
No particular example, but here are some relevant threads: • onetwo
🙌 1
a
@bashor is it safe to say that building times will also decrease?
would be great to be working only from the browser right now im working on desktop due to blazing fast iterations, and eventually i check the web version as it's slower to check
b
@Alex Styl for sure we are working on improving build time. Upcoming 2.1.0-Beta2+ has incremental compilation support for wasm targets reducing completion time up to 2 times. We’ll share more information with Beta2 release, stay tuned!
🙌 1
a
wow okay