Shave is a zero dependency javascript plugin that truncates multi-line text to fit within an html element based on a set max-height. It then stores the diff of the original text string in a hidden span element following the visible text. This means the original text remains intact.
Advantages of Shave:
– Maintains the original text after truncation
– Does not require other libraries
– Only requires a selector and a max height
– Is very lightweight – ~1.5kb unminified
– Allows for custom ellipsis strings and class names but doesn’t over complicate
Time elapsed for Shave to truncate 50 elements: 90 ms