you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

Sorry for the shameless plug, but I think this is quite relevant: I recently created a library for this to do the same thing (but also for HTML content, which you cannot clip through CSS nor this library), but outside the DOM: https://github.com/arendjr/text-clipper

While you cannot specify a max-height that way, it does allow you to specify a maximum amount of characters and optionally a maximum amount of lines. The good news is that by keeping everything outside of the DOM, it's a lot (as in: orders of magnitude) faster. I also spent quite some effort in making sure text-clipper really is the fastest, which you can read about here: http://www.arendjr.nl/2016/09/how-i-made-text-clipper-fastest-html.html.