Code: https://github.com/tdjsnelling/microtype Demo: https://tdjsnelling.github.io/microtype/test/from-cdn/
Even better, there is the new CSS `hyphens: auto;`. Browser & language support is not yet 100% though.
It's like talking about reflowing a physical page.
Instead, you change the document page size and render multiple versions and switch it out based on zoom level.
Texpresso looks promising though, but I haven’t tried it yet.
If you apply it to all paragraphs, yes, you will get pathological performance on some extreme cases—the algorithm is quadratic, if I recall correctly. But there’s nothing preventing you from trying to apply it in general, and giving up if the input is too long. So your five or ten line paragraphs get KP, and longer paragraphs get greedy.
There is absolutely nothing stopping browsers from applying Knuth-Plass. In fact, Firefox has had a bug about implementing it for 14 years <https://bugzilla.mozilla.org/show_bug.cgi?id=630181>, and there’s some useful discussion of things there. And CSS itself is finally actually going ahead with `text-wrap: pretty`, which encourages such things. Long ago, IE apparently even had it via `text-justify: newspaper` <https://news.ycombinator.com/item?id=5189258>.
https://courses.umass.edu/klement/imp/
which is available in a number of sizes _and_ has the LaTeX source available showing how the various sizes are arrived at.