3 ms·
Blog post author here. I don't know how small it can become because I haven't looked into optimizing for size yet. However, we can look to the native Qt libs to
by dragly 10y ago
Blog post author here. I don't know how small it can become because I haven't looked into optimizing for size yet. However, we can look to the native Qt libs to get a ballpark answer to your question. I just tried gzipping the binary .so files of QtCore, QtOpenGL and QtQuick on Ubuntu and that takes up 3.9 MB. That is likely a theoretical lower limit of what needs to be downloaded by the user, but I don't think we can expect anything close to that after compiling to JavaScript. Perhaps WebAssembly will help reduce the size in the future.
In any case, I wouldn't exactly recommend building a blog using Qt this way. If you want to try building websites with QML, qmlweb is much better suited. I rather expect Qt+NaCl/Emscripten to be useful for larger browser applications, like 3D graphics software, games, scientific simulators, and so on.
- flohofwoe 10y agoIn my experiments I found that gzipped asm.js is in the same ballpark as gzipped 64-bit x86 code. asm.js might come out 10..20% bigger, but not more. The absolutely important point is to make sure that the download is compressed (web servers typically do this for .js files). There is a static size overhead of up to a few hundred kbytes for C/C++ runtime code which needs to be included in the asm.js file, and which normally lives in system dlls when running as native code, but this can be optimized by trying to minimize the use of C++ (e.g. iostreams introduce quite terrible bloat, better to just use printf). A lot of work has gone into emscripten to optimize the output size, also very recently (e.g. a linker pass which scans the code for duplicate functions and removes them, which sometimes helps for code which makes heavy use of templates).
- deleted 10y ago[deleted]
- polymeris 10y agoWould dead code elimination be an option, if you are not using all of Qt?
- dragly 10y agoIn principle, yes, but I don't think Emscripten can do anything automatically the way things are now. The QML sandbox requires that almost all of QtCore and QtQuick is available because almost all code can be called by the user at runtime. Manually removing code you know is unused might be possible, though. I think I might have heard of some third-party tools that could help with this.