```We have a JS library that needs to be loaded on...
# javascript
j
Copy code
We have a JS library that needs to be loaded on the page to render some content. We are looking into moving some pieces of this library to KotlinJS. As such we have noticed that render performance on the page is very sensitive to our library's size, so we want to keep it as small as possible without any external dependencies. But so far it seems like JS generated by Kotlin has dependecy on `kotlin.js`, which needs to be loaded in browser before transpiled JS. We tried minifying+gziping kotlin.js, and it is still ~150kb in size, which is a deal breaker for us. So I wanted to confirm here if there is any possible way to not have to load `kotlin.js` and instead inline all the dependecies in the transpiled JS itself, or load only needed parts of it. Thanks.
g
I suggest checking out the DCE library to reduce the size of the libraries.
i
For now we can propose you to use the latest version of our gradle plugin, which is integrated with dead code elimination tool, which remove unnecessary code from bundle, and it is processed with webpack to minify it. To get JavaScript library you need some configuration You can check this sample https://github.com/ilgonmic/kotlinjs-multi-module Especially attention on
app
module and files: • https://github.com/ilgonmic/kotlinjs-multi-module/blob/master/app/build.gradle.kts -
dceTask
option
keep
is necessary to mark declarations, which you want to “save” in final bundle • https://github.com/ilgonmic/kotlinjs-multi-module/blob/master/app/webpack.config.d/library.js - it is additional configuration for webpack to enable library mode with
umd
target, so after you import you bundle on page, or require it in your script, you can get your functions
j
Thanks , will check out.