Improvements #11281

More tweaks to reduce installed size of Wt

Added by Emeric Poupon about 2 months ago. Updated about 2 months ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


Hello, it would be great to have more CMAKE options to remove unused parts of wt (to reduce the footprint for embedded applications, docker images, etc.)
For example Wt::Auth, Bootstrap2/3/5 (one option for each one), things like that
What do you think?


Updated by Roel Standaert about 2 months ago

I don't think removing Bootstrap themes will really make that much of a difference. A stripped MinSizeRel is 6.5 MiB on my machine (using dynamically linked dependencies), and a quick and dirty removal of the Bootstrap themes saves only 58 KiB. Removing Wt::Auth is a bit more significant, making it 6.1 MiB.

However, you'll find that you can save a lot more if you use static linking with garbage collection, the documentation is a bit outdated, but the concept is still the same. If I configure with:

-DCMAKE_C_FLAGS="-ffunction-sections -fdata-sections"
-DCMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections"

If I then do an install/strip hello.wt is only 1.9 MiB. Of course, I'm still using dynamically linked dependencies, for embedded applications you'd usually have statically linked dependencies built with similar options.

With those options, it shouldn't matter whether you're building Wt with Wt::Auth or Bootstrap themes. If you're not using them, they should get stripped out of your resulting executable entirely.

So I think it's probably not worth it. The feature flags that we do have are mostly related to which dependencies Wt requires.


Updated by Emeric Poupon about 2 months ago

Thanks for your answer!

Actually for the bootstrap themes I was thinking about the resources installed in Wt/resources/themes/bootstrap

$ du * -sh
540K    2
1.6M    3
7.5M    5

It makes a huge difference to dig into these resources and manually remove what is not necessary (default/polished theme, jplayer, bootstrap3, etc.)

Also available in: Atom PDF