And I have another question. Can we hide a `kotlin...
# javascript
a
And I have another question. Can we hide a
kotlin.js
file on website created using Kotlin/JS ? I download the kotlin.js file when I open this website(https://turanukimaru.github.io/FEHSIM/). So, I can’t find the website created by Kotlin/JS if we can hide a kotlin.js file. I saw it by network tab in chrome developer tools.
r
You can build the site with kotlin-fronted-plugin and webpack and have only a single bundle.js file included.
a
I see. Does it means that users don’t need to download related kotlin files? Because kotlin.js is so huge. It is about 1.8MB. Do users need to download the huge file every time? I’m sorry. I’m an android engineer. So I’m not good at web.
g
There is Kotlin DCE tool to minimize Kotlin js
👀 1
r
Using both DCE and webpack with UglifyJS plugin you can get a lot smaller bundle.
I've created a framework for kotlin/js and the smallest example app for it has bundle about 400KB (~ 120KB gziped). But it contains some libraries (including kotlinx.serialization), kotlin itself and some code of the framework of course.
Of course the more language features and libraries you use in your webapp, the larger the code will be.
a
Yes! I wanted know about the size of kotlin web apps. Thanks! I think we use a lot of libraries (coroutine, serialization, etc…) when we develop mpp apps. I think it is impossible to avoid downloading huge js file still now. Do you have another idea?
g
Depends on what is huge for you. Most of js frameworks are pretty big today
a
I think 400KB is huge. Because the size of hls.js which is playing video library is 75.3KB. And even the size of jquery is 80KB.
Anyway, I understand the size of Kotlin/JS. Thank you so much!
y
That is too huge.
r
Angular is ~1MB. And we should rather compare Kotlin/JS to Angular than to jQuery 😉
a
Hahaha. 😄
I saw the website of angularjs and I check the libraries. But the size of angular.js is 60 KB. 🤔 https://angularjs.org/
スクリーンショット 2019-07-12 0.41.04.jpg
Even the size of jQuery is 30KB. Hahaha
r
I was checking examples from http://todomvc.com website
And you are probably seeing gzipped sizes in browser console.
a
I see. And it is old version(v1.4.3) on todo site. It is v1.7.8 on angluerjs.org.
The todo website also uses gzip for an angular.js.😂
d
I made a small example of how to build the minimum JS on kotlin: https://github.com/avdim/kotlin-mpp-js-browser
👀 1
g
Also 400 kb is not gzipped, and it's actual application, not a hello world. Anyway, I wouldn't expect super-small Kotlin js files yet, after all it is another language, so it always have additional code for stdlib. There is work on new Kotlin/Js backend and it will allow to implement better DCE So on your place I would concider what is reasonable size for you. If you have super simple landing or 95% static website, maybe you just need a bit of vanilla JS (or even nothing), rather than bring frameworks for this
a
Yes, you are right. I understand we need the additional code for stdlib. I want to develop a mpp project that we can watch videos. It’s not simple website. Can I divide a Kotlin/JS code and download it in parallel? So, it’s no problem if we can download small js files in parallel.
g
Can I divide a Kotlin/JS code and download it in parallel?
It doesn’t really make sense, you will have a lot of resources that will run in parallel, also to run code you have to download all the parts together. Some dynamic feature loading may help of course
Just very funny comparison, for example super-highly optimised, but full of features YouTube has 1.2 Mb of gzipped JS, which is 6 Mb of unpacked JS code
Anyway, it’s really big topic how to optimize web site, you just should understand your use case and your tools and do not try to do premature optimisation before you have at least general understanding of problems that you have and approaches
You just should understand that yes, with Kotlin you get more JS code on the beginning, but when your app will grow it will be less and less part of your final app. Also if you have Video application, even static image preview (even if it’s highly optimized) would be 10-15KB, or 150KB for preview Gif (all sizes are from YouTube), not even talking about size of video
a
I’m sorry the example was not good. Its size is small compared to the image size. Anyway, I gain a deep understanding of Kotlin/JS. Thank you for teaching me so kindly! 😀
g
Its size is small compared to the image size.
hmm?
a
I am sorry that my English is so bad. It means that size of Kotlin/JS files are smaller than the size of images(gif, jpeg, png).